Our volunteers haven't translated this article into Bamanankan yet. Join us and help get the job done!
You can also read the article in English (US).

The Object constructor creates an object wrapper.

Syntax

// Object initialiser or literal
{ [ nameValuePair1[, nameValuePair2[, ...nameValuePairN] ] ] }

// Called as a constructor
new Object([value])

Parameters

nameValuePair1, nameValuePair2, ... nameValuePairN
Pairs of names (strings) and values (any value) where the name is separated from the value by a colon.
value
Any value.

Description

The Object constructor creates an object wrapper for the given value. If the value is null or undefined, it will create and return an empty object, otherwise, it will return an object of a Type that corresponds to the given value. If the value is an object already, it will return the value.

When called in a non-constructor context, Object behaves identically to new Object().

See also the object initializer / literal syntax.

Properties of the Object constructor

Object.length
Has a value of 1.
Object.prototype
Allows the addition of properties to all objects of type Object.

Methods of the Object constructor

Object.assign()
Copies the values of all enumerable own properties from one or more source objects to a target object.
Object.create()
Creates a new object with the specified prototype object and properties.
Object.defineProperty()
Adds the named property described by a given descriptor to an object.
Object.defineProperties()
Adds the named properties described by the given descriptors to an object.
Object.entries()
Returns an array containing all of the [key, value] pairs of a given object's own enumerable string properties.
Object.freeze()
Freezes an object: other code can't delete or change any properties.
Object.fromEntries()
Returns a new object from an iterable of key-value pairs (reverses Object.entries).
Object.getOwnPropertyDescriptor()
Returns a property descriptor for a named property on an object.
Object.getOwnPropertyDescriptors()
Returns an object containing all own property descriptors for an object.
Object.getOwnPropertyNames()
Returns an array containing the names of all of the given object's own enumerable and non-enumerable properties.
Object.getOwnPropertySymbols()
Returns an array of all symbol properties found directly upon a given object.
Object.getPrototypeOf()
Returns the prototype of the specified object.
Object.is()
Compares if two values are the same value. Equates all NaN values (which differs from both Abstract Equality Comparison and Strict Equality Comparison).
Object.isExtensible()
Determines if extending of an object is allowed.
Object.isFrozen()
Determines if an object was frozen.
Object.isSealed()
Determines if an object is sealed.
Object.keys()
Returns an array containing the names of all of the given object's own enumerable string properties.
Object.preventExtensions()
Prevents any extensions of an object.
Object.seal()
Prevents other code from deleting properties of an object.
Object.setPrototypeOf()
Sets the prototype (i.e., the internal [[Prototype]] property).
Object.values()
Returns an array containing the values that correspond to all of a given object's own enumerable string properties.

Object instances and Object prototype object

All objects in JavaScript are descended from Object; all objects inherit methods and properties from Object.prototype, although they may be overridden. For example, other constructors' prototypes override the constructor property and provide their own toString() methods. Changes to the Object prototype object are propagated to all objects unless the properties and methods subject to those changes are overridden further along the prototype chain.

Properties

Object.prototype.constructor
Specifies the function that creates an object's prototype.
Object.prototype.__proto__
Points to the object which was used as prototype when the object was instantiated.
Object.prototype.__noSuchMethod__
Allows a function to be defined that will be executed when an undefined object member is called as a method.
Object.prototype.__count__
Used to return the number of enumerable properties directly on a user-defined object, but has been removed.
Object.prototype.__parent__
Used to point to an object's context, but has been removed.

Methods

Object.prototype.__defineGetter__()
Associates a function with a property that, when accessed, executes that function and returns its return value.
Object.prototype.__defineSetter__()
Associates a function with a property that, when set, executes that function which modifies the property.
Object.prototype.__lookupGetter__()
Returns the function associated with the specified property by the __defineGetter__() method.
Object.prototype.__lookupSetter__()
Returns the function associated with the specified property by the __defineSetter__() method.
Object.prototype.hasOwnProperty()
Returns a boolean indicating whether an object contains the specified property as a direct property of that object and not inherited through the prototype chain.
Object.prototype.isPrototypeOf()
Returns a boolean indicating whether the object this method is called upon is in the prototype chain of the specified object.
Object.prototype.propertyIsEnumerable()
Returns a boolean indicating if the internal ECMAScript [[Enumerable]] attribute is set.
Object.prototype.toSource()
Returns string containing the source of an object literal representing the object that this method is called upon; you can use this value to create a new object.
Object.prototype.toLocaleString()
Calls toString().
Object.prototype.toString()
Returns a string representation of the object.
Object.prototype.unwatch()
Removes a watchpoint from a property of the object.
Object.prototype.valueOf()
Returns the primitive value of the specified object.
Object.prototype.watch()
Adds a watchpoint to a property of the object.
Object.prototype.eval()
Used to evaluate a string of JavaScript code in the context of the specified object, but has been removed.

Deleting a property from an object

There isn't any method in an Object itself to delete its own properties (e.g. like Map.prototype.delete()). To do so one has to use the delete operator.

Examples

Using Object given undefined and null types

The following examples store an empty Object object in o:

var o = new Object();
var o = new Object(undefined);
var o = new Object(null);

Using Object to create Boolean objects

The following examples store Boolean objects in o:

// equivalent to o = new Boolean(true);
var o = new Object(true);
// equivalent to o = new Boolean(false);
var o = new Object(Boolean());

Specifications

Specification Status Comment
ECMAScript 1st Edition (ECMA-262) Standard Initial definition. Implemented in JavaScript 1.0.
ECMAScript 5.1 (ECMA-262)
The definition of 'Object' in that specification.
Standard  
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Object' in that specification.
Standard Added Object.assign, Object.getOwnPropertySymbols, Object.setPrototypeOf, Object.is
ECMAScript Latest Draft (ECMA-262)
The definition of 'Object' in that specification.
Draft Added Object.entries, Object.values and Object.getOwnPropertyDescriptors.

Browser compatibility

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung InternetNode.js
Basic supportChrome Full support YesEdge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
prototypeChrome Full support YesEdge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
__count__
DeprecatedNon-standard
Chrome No support NoEdge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
__noSuchMethod__
DeprecatedNon-standard
Chrome No support NoEdge No support NoFirefox No support 1 — 43IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support 4 — 43Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
__parent__
DeprecatedNon-standard
Chrome No support NoEdge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
__proto__
Deprecated
Chrome Full support YesEdge Full support YesFirefox Full support 1IE Full support 11Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
constructorChrome Full support YesEdge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
assignChrome Full support 45Edge Full support YesFirefox Full support 34IE No support NoOpera Full support 32Safari Full support 9WebView Android No support NoChrome Android Full support 45Edge Mobile Full support YesFirefox Android Full support 34Opera Android No support NoSafari iOS Full support YesSamsung Internet Android Full support 5.0nodejs Full support 4.0.0
createChrome Full support 5Edge Full support YesFirefox Full support 4IE Full support 9Opera Full support 11.6Safari Full support 5WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.5Safari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
definePropertiesChrome Full support 5Edge Full support YesFirefox Full support 4IE Full support 9Opera Full support 11.6Safari Full support 5WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.5Safari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
definePropertyChrome Full support 5Edge Full support YesFirefox Full support 4IE Full support 9
Notes
Full support 9
Notes
Notes Also supported in Internet Explorer 8, but only on DOM objects and with some non-standard behaviors.
Opera Full support 11.6Safari Full support 5.1
Notes
Full support 5.1
Notes
Notes Also supported in Safari 5, but not on DOM objects.
WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 11.5Safari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
entriesChrome Full support 54Edge Full support 14Firefox Full support 47IE No support NoOpera Full support 41Safari Full support 10.1WebView Android Full support 54Chrome Android Full support 54Edge Mobile Full support YesFirefox Android Full support 47Opera Android Full support 41Safari iOS Full support 10.1Samsung Internet Android Full support 6.0nodejs Full support 7.0.0
Full support 7.0.0
Full support 6.5.0
Disabled
Disabled From version 6.5.0: this feature is behind the --harmony runtime flag.
freezeChrome Full support 6Edge Full support YesFirefox Full support 4IE Full support 9Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
fromEntriesChrome No support NoEdge No support NoFirefox Full support 63IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android Full support 63Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
getNotifier
DeprecatedNon-standard
Chrome No support 36 — 52Edge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
getOwnPropertyDescriptorChrome Full support 5Edge Full support YesFirefox Full support 4IE Full support 8Opera Full support 12Safari Full support 5WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
getOwnPropertyDescriptorsChrome Full support 54Edge Full support 15Firefox Full support 50IE No support NoOpera Full support 41Safari Full support 10WebView Android ? Chrome Android Full support 54Edge Mobile Full support YesFirefox Android Full support 50Opera Android ? Safari iOS ? Samsung Internet Android Full support 6.0nodejs Full support 7.0.0
Full support 7.0.0
Full support 6.5.0
Disabled
Disabled From version 6.5.0: this feature is behind the --harmony runtime flag.
getOwnPropertyNamesChrome Full support 5Edge Full support YesFirefox Full support 4IE Full support 9Opera Full support 12Safari Full support 5WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
getOwnPropertySymbolsChrome Full support 38Edge Full support YesFirefox Full support 36IE No support NoOpera Full support 25Safari Full support 9WebView Android Full support 38Chrome Android Full support 38Edge Mobile Full support YesFirefox Android Full support 36Opera Android Full support 25Safari iOS Full support 9Samsung Internet Android Full support Yesnodejs Full support 0.12
getPrototypeOfChrome Full support 5Edge Full support YesFirefox Full support 3.5IE Full support 9Opera Full support 12.1Safari Full support 5WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
isChrome Full support 30Edge Full support YesFirefox Full support 22IE No support NoOpera Full support YesSafari Full support 9WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 22Opera Android Full support YesSafari iOS Full support 9Samsung Internet Android Full support Yesnodejs Full support 0.10
isExtensibleChrome Full support 6Edge Full support YesFirefox Full support 4IE Full support 9Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
isFrozenChrome Full support 6Edge Full support YesFirefox Full support 4IE Full support 9Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
isSealedChrome Full support 6Edge Full support YesFirefox Full support 4IE Full support 9Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
keysChrome Full support 5Edge Full support YesFirefox Full support 4IE Full support 9Opera Full support 12Safari Full support 5WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
observe
DeprecatedNon-standard
Chrome No support 36 — 52Edge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
preventExtensionsChrome Full support 6Edge Full support YesFirefox Full support 4IE Full support 9Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
__defineGetter__
Deprecated
Chrome Full support YesEdge Full support YesFirefox Full support 1
Notes
Full support 1
Notes
Notes Starting with Firefox 48, this method can no longer be called at the global scope without any object. A TypeError will be thrown otherwise. Previously, the global object was used in these cases automatically, but this is no longer the case.
IE Full support 11Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
__defineSetter__
Deprecated
Chrome Full support YesEdge Full support YesFirefox Full support 1
Notes
Full support 1
Notes
Notes Starting with Firefox 48, this method can no longer be called at the global scope without any object. A TypeError will be thrown otherwise. Previously, the global object was used in these cases automatically, but this is no longer the case.
IE Full support 11Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
__lookupGetter__
Deprecated
Chrome Full support YesEdge Full support YesFirefox Full support 1IE Full support 11Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
__lookupSetter__
Deprecated
Chrome Full support YesEdge Full support YesFirefox Full support 1IE Full support 11Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
eval
DeprecatedNon-standard
Chrome No support NoEdge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
hasOwnPropertyChrome Full support YesEdge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
isPrototypeOfChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
propertyIsEnumerableChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
toLocaleStringChrome Full support YesEdge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
toSource
DeprecatedNon-standard
Chrome No support NoEdge No support NoFirefox Full support 1IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android Full support 4Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
toStringChrome Full support YesEdge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
unwatch
DeprecatedNon-standard
Chrome No support NoEdge No support NoFirefox No support 1 — 58IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support 4 — 58Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
valueOfChrome Full support YesEdge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
watch
DeprecatedNon-standard
Chrome No support NoEdge No support NoFirefox No support 1 — 58IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support 4 — 58Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
sealChrome Full support 6Edge Full support YesFirefox Full support 4IE Full support 9Opera Full support 12Safari Full support 5.1WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
setPrototypeOfChrome Full support 34Edge Full support YesFirefox Full support 31IE Full support 11Opera Full support YesSafari Full support 9WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 31Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support 0.12
unobserve
DeprecatedNon-standard
Chrome No support 36 — 52Edge No support NoFirefox No support NoIE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support Nonodejs No support No
valuesChrome Full support 54Edge Full support 14Firefox Full support 47IE No support NoOpera Full support 41Safari Full support 10.1WebView Android Full support 54Chrome Android Full support 54Edge Mobile Full support YesFirefox Android Full support 47Opera Android Full support 41Safari iOS Full support 10.3Samsung Internet Android Full support 6.0nodejs Full support 7.0.0
Full support 7.0.0
Full support 6.5.0
Disabled
Disabled From version 6.5.0: this feature is behind the --harmony runtime flag.

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.

See also