This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

Object

Summary

Provides functionality common to all JavaScript objects.

Syntax

obj  = new Object( [ value ] )
obj
Required. The variable name to which the Object object is assigned.
value
Optional. Any one of the JavaScript primitive data types (Number, Boolean, or String). If value is an object, the object is returned unmodified. If value is null , undefined , or not supplied, an object with no content is created.

Remarks

The Object object is contained in all other JavaScript objects; all of its methods and properties are available in all other objects. The methods can be redefined in user-defined objects, and are called by JavaScript at appropriate times. The toString method is an example of a frequently redefined Object method.

In this language reference, the description of each Object method includes both default and object-specific implementation information for the intrinsic JavaScript objects.

Properties

The following table lists properties of the Object Object.

PropertyDescription
constructor PropertySpecifies the function that creates an object.
prototype PropertyReturns a reference to the prototype for a class of objects.

Functions

The following table lists functions of the Object Object.

FunctionDescription
Object.create FunctionCreates an object that has a specified prototype, and that optionally contains specified properties.
Object.defineProperties FunctionAdds one or more properties to an object, and/or modifies attributes of existing properties.
Object.defineProperty FunctionAdds a property to an object, or modifies attributes of an existing property.
Object.freeze FunctionPrevents the modification of existing property attributes and values, and prevents the addition of new properties.
Object.getOwnPropertyDescriptor FunctionReturns the definition of a data property or an accessor property.
Object.getOwnPropertyNames FunctionReturns the names of the properties and methods of an object.
Object.getPrototypeOf FunctionReturns the prototype of an object.
Object.isExtensible FunctionReturns a value that indicates whether new properties can be added to an object.
Object.isFrozen FunctionReturns true if existing property attributes and values cannot be modified in an object and new properties cannot be added to the object.
Object.isSealed FunctionReturns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object.
Object.keys FunctionReturns the names of the enumerable properties and methods of an object.
Object.preventExtensions FunctionPrevents the addition of new properties to an object.
Object.seal FunctionPrevents the modification of attributes of existing properties, and prevents the addition of new properties.

Methods

The following table lists methods of the Object Object.

MethodDescription
hasOwnProperty methodReturns a Boolean value that indicates whether an object has a property with the specified name.
isPrototypeOf methodReturns a Boolean value that indicates whether an object exists in another object’s prototype hierarchy.
propertyIsEnumerable methodReturns a Boolean value that indicates whether a specified property is part of an object and whether it is enumerable.
toLocaleString methodReturns an object converted to a string based on the current locale.
toString methodReturns a string representation of an object.
valueOf methodReturns the primitive value of the specified object.

See also

Other articles

Attributions

  • Microsoft Developer Network: Article