--- title: Object slug: Web/JavaScript/Reference/Global_Objects/Object tags: - Constructor - JavaScript - NeedsTranslation - Object - TopicStub translation_of: Web/JavaScript/Reference/Global_Objects/Object ---
Object 建構式可用於建立物件包裝(object wrapper)。
// Object initialiser or literal
{ [ nameValuePair1[, nameValuePair2[, ...nameValuePairN] ] ] }
// Called as a constructor
new Object([value])
nameValuePair1, nameValuePair2, ... nameValuePairNvalueThe Object constructor creates an object wrapper for the given value. If the value is {{jsxref("null")}} or {{jsxref("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().
也可以參考 object initializer / literal syntax.
Object 建構式屬性Object.lengthObject 建構式方法[key, value] pairs.[[Prototype]] property)Object 物件實體與 Object 原型物件All objects in JavaScript are descended from Object; all objects inherit methods and properties from {{jsxref("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 given undefined and null types下面例子儲存一個空物件至變數o
var o = new Object();
var o = new Object(undefined);
var o = new Object(null);
Object to create Boolean objects下面例子儲存 {{jsxref("Boolean")}} 物件在 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 | 
|---|---|---|
| {{SpecName('ES1')}} | {{Spec2('ES1')}} | Initial definition. Implemented in JavaScript 1.0. | 
| {{SpecName('ES5.1', '#sec-15.2', 'Object')}} | {{Spec2('ES5.1')}} | |
| {{SpecName('ES6', '#sec-object-objects', 'Object')}} | {{Spec2('ES6')}} | Added Object.assign, Object.getOwnPropertySymbols, Object.setPrototypeOf, Object.is | 
| {{SpecName('ESDraft', '#sec-object-objects', 'Object')}} | {{Spec2('ESDraft')}} | Added Object.entries, Object.values and Object.getOwnPropertyDescriptors. | 
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari | 
|---|---|---|---|---|---|
| Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | 
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | 
|---|---|---|---|---|---|---|
| Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |