|
2 | 2 | {{alias}}( obj, prop, descriptor )
|
3 | 3 | Defines a property.
|
4 | 4 |
|
| 5 | + Property descriptors come in two flavors: data descriptors and accessor |
| 6 | + descriptors. A data descriptor is a property that has a value, which may or |
| 7 | + may not be writable. An accessor descriptor is a property described by a |
| 8 | + getter-setter function pair. A descriptor must be one of these two flavors |
| 9 | + and cannot be both. |
| 10 | + |
5 | 11 | Parameters
|
6 | 12 | ----------
|
7 | 13 | obj: Object
|
|
13 | 19 | descriptor: Object
|
14 | 20 | Property descriptor.
|
15 | 21 |
|
| 22 | + descriptor.configurable: boolean (optional) |
| 23 | + Boolean indicating if property descriptor can be changed and if the |
| 24 | + property can be deleted from the provided object. Default: false. |
| 25 | + |
| 26 | + descriptor.enumerable: boolean (optional) |
| 27 | + Boolean indicating if the property shows up when enumerating object |
| 28 | + properties. Default: false. |
| 29 | + |
| 30 | + descriptor.writable: boolean (optional) |
| 31 | + Boolean indicating if the value associated with the property can be |
| 32 | + changed with an assignment operator. Default: false. |
| 33 | + |
| 34 | + descriptor.value: any (optional) |
| 35 | + Property value. |
| 36 | + |
| 37 | + descriptor.get: Function|void (optional) |
| 38 | + Function which serves as a getter for the property, or, if no getter, |
| 39 | + undefined. When the property is accessed, a getter function is called |
| 40 | + without arguments and with the `this` context set to the object through |
| 41 | + which the property is accessed (which may not be the object on which the |
| 42 | + property is defined due to inheritance). The return value will be used |
| 43 | + as the property value. Default: undefined. |
| 44 | + |
| 45 | + descriptor.set: Function|void (optional) |
| 46 | + Function which serves as a setter for the property, or, if no setter, |
| 47 | + undefined. When assigning a property value, a setter function is called |
| 48 | + with one argument (the value being assigned to the property) and with |
| 49 | + the `this` context set to the object through which the property is |
| 50 | + assigned. Default: undefined. |
| 51 | + |
16 | 52 | Examples
|
17 | 53 | --------
|
18 | 54 | > var obj = {};
|
|
0 commit comments