JavaScripture
Home Feedback

JavaScript Object

Object is the base in the prototype chain.

Object() : Object

Creates an empty object. Can also be constructed as {}.

Example:

Run

Results:

 
Object(value : Object) : Object

If value is a primitive type, creates a box for value. Otherwise, returns value.

Example:

Run

Results:

 

Constructors

new Object() : Object

Same as Object().

new Object(value : Object) : Object

Same as Object(value).

Instance Methods

constructor : Function

The Function that constructed this.

Example:

Run

Results:

 
hasOwnProperty(propertyName : String) : Boolean

Returns true if this has a property named propertyName stored on it. This method can be used to see if a property is set on the object, even if the value is set to undefined. Properties stored in the prototype chain do not count.

Example:

Run

Results:

 
isPrototypeOf(obj : Object) : Boolean

Returns true if this is in the prototype chain of obj.

Example:

Run

Results:

 
propertyIsEnumerable(propertyName : String) : Boolean

Returns true if the property named propertyName on this is enumerable and should be returned during a for (x in y) loop.

Example:

Run

Results:

 
toLocaleString() : String

Returns a locale specific (if possible) string representation of this.

Example:

Run

Results:

 
toString() : String

Returns a string representation of this. This method is called each time the object is used in a place a string is expected. Define your own toString to give a better string representation to your objects.

Example:

Run

Results:

 
valueOf() : Object

For boxed primitive types, returns the unboxed value.

Example:

Run

Results:

 

Object Methods

create(prototype : Object, [propertyDescriptors : Object]) : Object

Returns a new Object with prototype equal to prototype. Each property on propertyDescriptors will be added to the new object.

Example:

Run

Results:

 
defineProperties(obj : Object, propertyDescriptors : Object) : Object

For each property on propertyDescriptors, defines a new property on obj with the same name and supplied descripton. Returns obj.

Example:

Run

Results:

 
defineProperty(obj : Object, propertyName : String, propertyDescriptor : Object) : Object

Defines a new property with name equal to propertyName on obj with the supplied description. Returns obj.

Example:

Run

Results:

 
freeze(obj : Object) : Object

For each property on obj, sets its property description's configurable property to false and writable property to false. Also calls preventExtensions on obj. Returns obj.

Example:

Run

Results:

 
getOwnPropertyDescriptor(obj : Object, propertyName : String) : Object

Returns an Object that describes the propertyName property on obj.

Example:

Run

Results:

 
getOwnPropertyNames(obj : Object) : Array

Returns an Array of the names of all properties set on obj including those that are not enumerable.

Example:

Run

Results:

 
getPrototypeOf(obj : Object) : Object

Returns the prototype of obj.

Example:

Run

Results:

 
isExtensible(obj : Object) : Boolean

Returns false if preventExtensions was called on obj. A non-extensible object cannot have new properties added to it.

Example:

Run

Results:

 
isFrozen(obj : Object) : Boolean

Returns true if freeze was called on obj. A frozen object cannot have new properties added and existing properties cannot be modified.

Example:

Run

Results:

 
isSealed(obj : Object) : Boolean

Returns true if seal was called on obj. A sealed object cannot have new properties added to it but the value of existing properties can be changed.

Example:

Run

Results:

 
keys(obj : Object) : Array

Returns an Array containing the enumerable properties on obj.

Example:

Run

Results:

 
preventExtensions(obj : Object) : Object

Prevents new properties from being added to obj. Unlike freeze, existing properties can be modified. Returns obj.

Example:

Run

Results:

 
seal(obj : Object) : Object

Same as preventExtensions except it also sets each property as not configurable. Returns obj.

Example:

Run

Results: