time-to-botec

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

repl.txt (2473B)


      1 
      2 {{alias}}( obj, prop, descriptor )
      3     Defines (or modifies) an object property.
      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 
     11     Parameters
     12     ----------
     13     obj: Object
     14         Object on which to define the property.
     15 
     16     prop: string|symbol
     17         Property name.
     18 
     19     descriptor: Object
     20         Property descriptor.
     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 
     52     Returns
     53     -------
     54     obj: Object
     55         Object on which the property was defined (or modified).
     56 
     57     Examples
     58     --------
     59     > var obj = {};
     60     > {{alias}}( obj, 'foo', {
     61     ...     'value': 'bar',
     62     ...     'enumerable': true,
     63     ...     'writable': false
     64     ... });
     65     > obj.foo = 'boop';
     66     > obj
     67     { 'foo': 'bar' }
     68 
     69     See Also
     70     --------
     71