Object

  • Tags
  • Files

요약

객체 레퍼 생성.

문법

new Object( [ value ] )

파라미터

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.

I'm pretty sure the following is true. The only difference I can see according to the spec is that when called as a constructor, there are provisions to handle host objects differently than simply returning themWhen called in a non-constructor context, Object behaves identically.

Properties

For properties available on Object instances, see Properties of Object instances.

prototype
Object 타입의 모든 객체에게 다른 속성들을 추가할 수 있게 한다.

Properties inherited from Function:
arity, caller, constructor, length, name

Methods

For methods available on Object instances, see Methods of Object instances.

create
Requires JavaScript 1.8.5
특정 프로토타입 객체와 속성을 가진 새로운 객체를 만듬
Creates a new object with the specified prototype object and properties.
defineProperty
Requires JavaScript 1.8.5
Adds the named property described by a given descriptor to an object.
defineProperties
Requires JavaScript 1.8.5
Adds the named properties described by the given descriptors to an object.
getOwnPropertyDescriptor
Requires JavaScript 1.8.5
Returns a property descriptor for a named property on an object.
keys
Requires JavaScript 1.8.5
Returns an array containing the names of all of the given object's own enumerable properties.
getOwnPropertyNames
Requires JavaScript 1.8.5
Returns an array containing the names of all of the given object's own enumerable and non-enumerable properties.
getPrototypeOf
Requires JavaScript 1.8.1
Returns the prototype of the specified object.
preventExtensions
Requires JavaScript 1.8.5
Prevents any extensions of an object.
isExtensible
Requires JavaScript 1.8.5
Determine if extending of an object is allowed.
seal
Requires JavaScript 1.8.5
Prevents other code from deleting properties of an object.
isSealed
Requires JavaScript 1.8.5
Determine if an object is sealed.
freeze
Requires JavaScript 1.8.5
Freezes an object: other code can't delete or change any properties.
isFrozen
Requires JavaScript 1.8.5
Determine if an object was frozen.

Methods inherited from Function:
apply, call, toSource, toString

Object instances

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

constructor
Specifies the function that creates an object's prototype.
__count__
Obsolete since JavaScript 1.8.5
Returns the number of enumerable properties directly on a user-defined object.
__parent__
Obsolete since JavaScript 1.8.5
Points to an object's context.
__proto__
Non-standard
Points to the object which was used as prototype when the object was instantiated.

Methods

constructor
Specifies the function that creates an object's prototype.
__count__
Obsolete since JavaScript 1.8.5
Returns the number of enumerable properties directly on a user-defined object.
__parent__
Obsolete since JavaScript 1.8.5
Points to an object's context.
__proto__
Non-standard
Points to the object which was used as prototype when the object was instantiated.

Examples

Example: 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);

Example: 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());

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support ? (Yes) ? ? ?
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? (Yes) ? ? ?

이 페이지의 공헌자: Jeado.Ko
Last updated by: Jeado.Ko,
Last reviewed by: Jeado.Ko,