Object

Resumen

Crea un contenedor de objeto

Sintáxis

new Object( [ valor ] )

Parámetros

valor
Cualquier valor.

Descripción

El constructor Object crea un contenedor de objeto para el valor dado. Si el valor es null o undefined, creará y devolverá un objeto vacio, de cualquier otro modo, este retornará un objeto del tipo correspondiente al valor dado.

Cuando es llamado en un contexto no-constructor, Object se comporta de manera similar.

Propiedades

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

Prototype
Permite agregar propiedades a todos los objetos del tipo Object
Properties inherited from Function:

Métodos

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

create Requires JavaScript 1.8.5
Crea un nuevo objeto con el prototype específico y con propiedades.
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.
is Firefox 22
Compares if two values are distinguishable (ie. the same)
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:

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

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 indication whether the specified object is in the prototype chain of the object this method is called upon.
Object.prototype.propertyIsEnumerable()
Returns a boolean indicating if the internal ECMAScript DontEnum 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.

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) (Yes) ? ? ?
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? (Yes) ? ? (Yes)

 

 

Etiquetas y colaboradores del documento

Colaboradores de esta página: Sheppy, Talisker, neosergio, Mgjbot
Última actualización por: neosergio,