Object.prototype.__defineSetter__()

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

Deprecated
This feature has been removed from the Web. Though some browsers may still support it, it is in the process of being dropped. Do not use it in old or new projects. Pages or Web apps using it may break at any time.

Summary

The __defineSetter__ method binds an object's property to a function to be called when an attempt is made to set that property.

Syntax

obj.__defineSetter__(sprop, fun)

Parameters

sprop
A string containing the name of the property to be bound to the given function
fun
A function to be called when there is an attempt to set the specified property. This function takes the form
function (val) { . . . }
val
an alias for the variable that holds the value attempted to be assigned to prop

Description

The __defineSetter__ method allows a setter to be defined on a pre-existing object.

Specifications

Not part of any specifications.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) IE 11 (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) ? (Yes) (Yes)

See also

Document Tags and Contributors

Contributors to this page: evilpie, Sheppy, fscholz, Sevenspade, ethertank, trevorh, Mgjbot
Last updated by: fscholz,