Object Atom feed

Object is used by Prototype as a namespace; that is, it just keeps a few new methods together, which are intended for namespaced access (i.e. starting with “Object.”).

For the regular developer (who simply uses Prototype without tweaking it), the most commonly used methods are probably inspect and, to a lesser degree, clone.

Advanced users, who wish to create their own objects like Prototype does, or explore objects as if they were hashes, will turn to extend, keys and values.

Methods

clone

Object.clone(obj) -> Object

Clones the passed object using shallow copy (copies all the original’s properties to the result).

extend

Object.extend(dest, src) -> alteredDest

Copies all properties from the source to the destination object. Used by Prototype to simulate inheritance (rather statically) by copying to prototypes.

inspect

Object.inspect(obj) -> String

Returns the debug-oriented string representation of the object.

isArray
1.6

isArray(obj) -> Boolean

Returns true if obj is an array, false otherwise.

isElement
1.6

isElement(obj) -> Boolean

Returns true if obj is a DOM node of type 1, false otherwise.

isFunction
1.6

isFunction(obj) -> Boolean

Returns true if obj is of type function, false otherwise.

isHash
1.6

isHash(obj) -> Boolean

Returns true if obj is an instance of the Hash class, false otherwise.

isNumber
1.6

isNumber(obj) -> Boolean

Returns true if obj is of type number, false otherwise.

isString
1.6

isString(obj) -> Boolean

Returns true if obj is of type string, false otherwise.

isUndefined
1.6

isUndefined(obj) -> Boolean

Returns true if obj is of type undefined, false otherwise.

keys

Object.keys(obj) -> [String...]

Treats any object as a Hash and fetches the list of its property names.

toHTML
1.6

toHTML(obj) -> String

Returns the return value of obj’s toHTML method if it exists, else runs obj through String.interpret.

toJSON
1.5.1

toJSON(obj) -> String

Returns a JSON string.

toQueryString
1.6

toQueryString(obj) -> String

Turns an object into its URL-encoded query string representation.

values

Object.values(obj) -> Array

Treats any object as a Hash and fetches the list of its property values.