Skip to content

Object Functions

Rohan Singh edited this page Apr 12, 2015 · 11 revisions

object values have the following functions defined.

add

add(key, value)

Adds or overwrites a key-value pair in the object.

clear

clear()

Removes all values from the object.

containsKey

containsKey(key): bool

Returns true if the object contains the given key.

containsValue

containsValue(value): bool

Returns true if the object contains the given value.

get

get(key): any

Returns the value for the given key, or undefined if it was not found.

remove

remove(key): bool

Removes a key from the object. Returns true if the key was found and removed.

length

length(): number

Returns the number of key-value pairs defined in the object. This does not include values inherited from the prototype.

getEnumerator

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

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

lock(): object

Locks the object, preventing further modifications to it.

setPrototypeAndLock

setPrototypeAndLock(value: any): object

Set's the object's prototype and locks the object.