Object is used by Prototype as a namespace and to call related function using Object object. This is used in the following two ways −
If you are a simple developer, then you can use the existing functions like inspect or clone.
If you are one who wishes to create their own objects like Prototype does, or explore objects as if they were hashes, will turn to extend, keys and values.
NOTE − Make sure at least have the version 1.6 of prototype.js.
S.No. | Method & Description |
---|---|
1. | clone()
Clones the passed object using shallow copy (copies all the original's properties to the result). |
2. | extend()
Copies all properties from the source to the destination object. |
3. | inspect()
Returns the debug-oriented string representation of the object. |
4. | isArray ()
Returns true if obj is an array, false otherwise. |
5. | isElement()
Returns true if obj is a DOM node of type 1, false otherwise. |
6. | isFunction()
Returns true if obj is of type function, false otherwise. |
7. | isHash()
Returns true if obj is an instance of the Hash class, false otherwise. |
8. | isNumber()
Returns true if obj is of type number, false otherwise. |
9. | isString()
Returns true if obj is of type string, false otherwise. |
10. | isUndefined()
Returns true if obj is of type undefined, false otherwise. |
11. | keys()
Treats any object as a Hash and fetches the list of its property names. |
12. | toHTML()
Returns the return value of obj's toHTML method if it exists, else runs obj through String.interpret. |
13. | toJSON()
Returns a JSON string. |
14. | toQueryString()
Turns an object into its URL-encoded query string representation. |
15. | values()
Treats any object as a Hash and fetches the list of its property values. |