time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

repl.txt (2504B)


      1 
      2 {{alias}}( obj, properties )
      3     Defines (and/or modifies) object properties.
      4 
      5     The second argument is an object whose own enumerable property values are
      6     descriptors for the properties to be defined or modified.
      7 
      8     Property descriptors come in two flavors: data descriptors and accessor
      9     descriptors. A data descriptor is a property that has a value, which may or
     10     may not be writable. An accessor descriptor is a property described by a
     11     getter-setter function pair. A descriptor must be one of these two flavors
     12     and cannot be both.
     13 
     14     A property descriptor has the following optional properties:
     15 
     16     - configurable: boolean indicating if property descriptor can be changed and
     17     if the property can be deleted from the provided object. Default: false.
     18 
     19     - enumerable: boolean indicating if the property shows up when enumerating
     20     object properties. Default: false.
     21 
     22     - writable: boolean indicating if the value associated with the property can
     23     be changed with an assignment operator. Default: false.
     24 
     25     - value: property value.
     26 
     27     - get: function which serves as a getter for the property, or, if no getter,
     28     undefined. When the property is accessed, a getter function is called
     29     without arguments and with the `this` context set to the object through
     30     which the property is accessed (which may not be the object on which the
     31     property is defined due to inheritance). The return value will be used as
     32     the property value. Default: undefined.
     33 
     34     - set: function which serves as a setter for the property, or, if no setter,
     35     undefined. When assigning a property value, a setter function is called with
     36     one argument (the value being assigned to the property) and with the `this`
     37     context set to the object through which the property is assigned. Default: undefined.
     38 
     39     Parameters
     40     ----------
     41     obj: Object
     42         Object on which to define the properties.
     43 
     44     properties: Object
     45         Object with property descriptors.
     46 
     47     Returns
     48     -------
     49     obj: Object
     50         Object on which properties were defined (and/or modified).
     51 
     52     Examples
     53     --------
     54     > var obj = {};
     55     > {{alias}}( obj, {
     56     ...     'foo': {
     57     ...         'value': 'bar',
     58     ...         'writable': false,
     59     ...         'configurable': false,
     60     ...         'enumerable': true
     61     ...     },
     62     ...     'baz': {
     63     ...         'value': 13
     64     ...     }
     65     ... });
     66     > obj.foo
     67     'bar'
     68     > obj.baz
     69     13
     70 
     71     See Also
     72     --------
     73