-
Notifications
You must be signed in to change notification settings - Fork 24
Object Functions
object
values have the following functions defined.
Note: Unless otherwise stated, the functions that return object
just return the value they acted on, not a new value. This enables calls to be chained like this: {}.add('a', 1).add('b', 2)
add(key, value): object
Adds or overwrites a key-value pair in the object.
clear(): object
Removes all values from the object, including any user-defined prototype
value.
containsKey(key): bool
Returns true
if the object contains the given key.
containsValue(value): bool
Returns true
if the object contains the given value.
get(key): any
Returns the value for the given key, or undefined
if it was not found.
remove(key): object
Removes a key from the object.
length(): number
Returns the number of key-value pairs defined in the object. This does not include values inherited from the prototype.
getEnumerator(): object
Returns an enumerator for iterating over values defined in the object. Values will be returned as key-value pair objects: { key: 'age', value: 12 }
prototype(value: any): object
Sets the object's prototype. value
should be an object
, null
, or undefined
. null
terminates the prototype chain while undefined
will restore the default prototype.