Object
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.
Методы
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
isArray(obj) -> Boolean
Returns true if obj is an array, false otherwise.
isElement
isElement(obj) -> Boolean
Returns true if obj is a DOM node of type 1, false otherwise.
isFunction
isFunction(obj) -> Boolean
Returns true if obj is of type function, false otherwise.
isHash
isHash(obj) -> Boolean
Returns true if obj is an instance of the Hash class, false otherwise.
isNumber
isNumber(obj) -> Boolean
Returns true if obj is of type number, false otherwise.
isString
isString(obj) -> Boolean
Returns true if obj is of type string, false otherwise.
isUndefined
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
toHTML(obj) -> String
Returns the return value of obj’s toHTML method if it exists, else runs obj through String.interpret.
toJSON
toJSON(obj) -> String
Returns a JSON string.
toQueryString
toQueryString(obj) -> String
Turns an object into its URL-encoded query string representation.