The Object
constructor creates an object wrapper.
// Object initialiser or literal { [ nameValuePair1[, nameValuePair2[, ...nameValuePairN] ] ] } // Called as a constructor new Object([value])
nameValuePair1, nameValuePair2, ... nameValuePairN
value
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.
Object
constructorObject.length
Object.prototype
Object
constructorObject.assign()
Object.create()
Object.defineProperty()
Object.defineProperties()
Object.entries()
[key, value]
pairs of a given object's own enumerable string properties.Object.freeze()
Object.fromEntries()
Object.entries
).Object.getOwnPropertyDescriptor()
Object.getOwnPropertyDescriptors()
Object.getOwnPropertyNames()
Object.getOwnPropertySymbols()
Object.getPrototypeOf()
Object.is()
Object.isExtensible()
Object.isFrozen()
Object.isSealed()
Object.keys()
Object.preventExtensions()
Object.seal()
Object.setPrototypeOf()
[[Prototype]]
property).Object.values()
Object
instances and Object
prototype objectAll 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.
Object.prototype.constructor
Object.prototype.__proto__
Object.prototype.__noSuchMethod__
Object.prototype.__count__
Object.prototype.__parent__
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
__defineGetter__()
method.Object.prototype.__lookupSetter__()
__defineSetter__()
method.Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toSource()
Object.prototype.toLocaleString()
toString()
.Object.prototype.toString()
Object.prototype.unwatch()
Object.prototype.valueOf()
Object.prototype.watch()
Object.prototype.eval()
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.
Object
given undefined
and null
typesThe following examples store an empty Object
object in o
:
var o = new Object();
var o = new Object(undefined);
var o = new Object(null);
Object
to create Boolean
objectsThe 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());
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. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | 1 | Yes | Yes | Yes |
prototype |
Yes | Yes | 1 | Yes | Yes | Yes |
__count__
|
No | No | No | No | No | No |
__noSuchMethod__
|
No | No | 1 — 43 | No | No | No |
__parent__
|
No | No | No | No | No | No |
__proto__
|
Yes | Yes | 1 | 11 | Yes | Yes |
constructor |
Yes | Yes | 1 | Yes | Yes | Yes |
assign |
45 | Yes | 34 | No | 32 | 9 |
create |
5 | Yes | 4 | 9 | 11.6 | 5 |
defineProperties |
5 | Yes | 4 | 9 | 11.6 | 5 |
defineProperty |
5 | Yes | 4 | 9
|
11.6 | 5.1
|
entries |
54 | 14 | 47 | No | 41 | 10.1 |
freeze |
6 | Yes | 4 | 9 | 12 | 5.1 |
fromEntries |
No | No | 63 | No | No | No |
getNotifier
|
36 — 52 | No | No | No | No | No |
getOwnPropertyDescriptor |
5 | Yes | 4 | 8 | 12 | 5 |
getOwnPropertyDescriptors |
54 | 15 | 50 | No | 41 | 10 |
getOwnPropertyNames |
5 | Yes | 4 | 9 | 12 | 5 |
getOwnPropertySymbols |
38 | Yes | 36 | No | 25 | 9 |
getPrototypeOf |
5 | Yes | 3.5 | 9 | 12.1 | 5 |
is |
30 | Yes | 22 | No | Yes | 9 |
isExtensible |
6 | Yes | 4 | 9 | 12 | 5.1 |
isFrozen |
6 | Yes | 4 | 9 | 12 | 5.1 |
isSealed |
6 | Yes | 4 | 9 | 12 | 5.1 |
keys |
5 | Yes | 4 | 9 | 12 | 5 |
observe
|
36 — 52 | No | No | No | No | No |
preventExtensions |
6 | Yes | 4 | 9 | 12 | 5.1 |
__defineGetter__
|
Yes | Yes | 1
|
11 | Yes | Yes |
__defineSetter__
|
Yes | Yes | 1
|
11 | Yes | Yes |
__lookupGetter__
|
Yes | Yes | 1 | 11 | Yes | Yes |
__lookupSetter__
|
Yes | Yes | 1 | 11 | Yes | Yes |
eval
|
No | No | No | No | No | No |
hasOwnProperty |
Yes | Yes | 1 | Yes | Yes | Yes |
isPrototypeOf |
Yes | Yes | Yes | Yes | Yes | Yes |
propertyIsEnumerable |
Yes | Yes | Yes | Yes | Yes | Yes |
toLocaleString |
Yes | Yes | 1 | Yes | Yes | Yes |
toSource
|
No | No | 1 | No | No | No |
toString |
Yes | Yes | 1 | Yes | Yes | Yes |
unwatch
|
No | No | 1 — 58 | No | No | No |
valueOf |
Yes | Yes | 1 | Yes | Yes | Yes |
watch
|
No | No | 1 — 58 | No | No | No |
seal |
6 | Yes | 4 | 9 | 12 | 5.1 |
setPrototypeOf |
34 | Yes | 31 | 11 | Yes | 9 |
unobserve
|
36 — 52 | No | No | No | No | No |
values |
54 | 14 | 47 | No | 41 | 10.1 |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | 4 | Yes | Yes | Yes |
prototype |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
__count__
|
No | No | No | No | No | No | No |
__noSuchMethod__
|
No | No | No | 4 — 43 | No | No | No |
__parent__
|
No | No | No | No | No | No | No |
__proto__
|
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
constructor |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
assign |
No | 45 | Yes | 34 | No | Yes | 5.0 |
create |
Yes | Yes | Yes | 4 | 11.5 | Yes | Yes |
defineProperties |
Yes | Yes | Yes | 4 | 11.5 | Yes | Yes |
defineProperty |
Yes | Yes | Yes | 4 | 11.5 | Yes | Yes |
entries |
54 | 54 | Yes | 47 | 41 | 10.1 | 6.0 |
freeze |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
fromEntries |
No | No | No | 63 | No | No | No |
getNotifier
|
No | No | No | No | No | No | No |
getOwnPropertyDescriptor |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
getOwnPropertyDescriptors |
? | 54 | Yes | 50 | ? | ? | 6.0 |
getOwnPropertyNames |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
getOwnPropertySymbols |
38 | 38 | Yes | 36 | 25 | 9 | Yes |
getPrototypeOf |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
is |
Yes | Yes | Yes | 22 | Yes | 9 | Yes |
isExtensible |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
isFrozen |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
isSealed |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
keys |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
observe
|
No | No | No | No | No | No | No |
preventExtensions |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
__defineGetter__
|
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
__defineSetter__
|
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
__lookupGetter__
|
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
__lookupSetter__
|
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
eval
|
No | No | No | No | No | No | No |
hasOwnProperty |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
isPrototypeOf |
Yes | Yes | Yes | Yes | Yes | Yes | Yes |
propertyIsEnumerable |
Yes | Yes | Yes | Yes | Yes | Yes | Yes |
toLocaleString |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
toSource
|
No | No | No | 4 | No | No | No |
toString |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
unwatch
|
No | No | No | 4 — 58 | No | No | No |
valueOf |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
watch
|
No | No | No | 4 — 58 | No | No | No |
seal |
Yes | Yes | Yes | 4 | Yes | Yes | Yes |
setPrototypeOf |
Yes | Yes | Yes | 31 | Yes | Yes | Yes |
unobserve
|
No | No | No | No | No | No | No |
values |
54 | 54 | Yes | 47 | 41 | 10.3 | 6.0 |
Server | |
---|---|
Node.js | |
Basic support | Yes |
prototype |
Yes |
__count__
|
No |
__noSuchMethod__
|
No |
__parent__
|
No |
__proto__
|
Yes |
constructor |
Yes |
assign |
4.0.0 |
create |
Yes |
defineProperties |
Yes |
defineProperty |
Yes |
entries |
7.0.0
|
freeze |
Yes |
fromEntries |
No |
getNotifier
|
No |
getOwnPropertyDescriptor |
Yes |
getOwnPropertyDescriptors |
7.0.0
|
getOwnPropertyNames |
Yes |
getOwnPropertySymbols |
0.12 |
getPrototypeOf |
Yes |
is |
0.10 |
isExtensible |
Yes |
isFrozen |
Yes |
isSealed |
Yes |
keys |
Yes |
observe
|
No |
preventExtensions |
Yes |
__defineGetter__
|
Yes |
__defineSetter__
|
Yes |
__lookupGetter__
|
Yes |
__lookupSetter__
|
Yes |
eval
|
No |
hasOwnProperty |
Yes |
isPrototypeOf |
Yes |
propertyIsEnumerable |
Yes |
toLocaleString |
Yes |
toSource
|
No |
toString |
Yes |
unwatch
|
No |
valueOf |
Yes |
watch
|
No |
seal |
Yes |
setPrototypeOf |
0.12 |
unobserve
|
No |
values |
7.0.0
|
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object