-
Notifications
You must be signed in to change notification settings - Fork 24
Object Functions
object
values have the following functions defined.
- add
- clear
- containsKey
- containsValue
- get
- remove
- length
- getEnumerator
- setPrototype
- lock
- setPrototypeAndLock
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 }
setPrototype(value: any): object
Sets the object's prototype. value
should be an object
, null
, or undefined
. null
will remove the prototype while undefined
will restore the default prototype.
lock(): object
Locks the object, preventing further modifications to it.
setPrototypeAndLock(value: any): object
Set's the object's prototype and locks the object.