--- title: Object slug: Web/JavaScript/Referencia/Objetos_globales/Object tags: - Constructor - JavaScript - Objeto - Referencia translation_of: Web/JavaScript/Reference/Global_Objects/Object ---
{{JSRef}}
La clase Object representa uno de los tipos de datos de Javascript. Es es usado para guardar una colección de datos definidos y entidades más complejas. Los objetos pueden ser creados utilzando el constructor {{jsxref("Object/Object", "Object()")}} o la sintaxis literal de objeto. 

El constructor Object crea una envoltura al objeto.

Sintaxis

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

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

Parámetros

nameValuePair1, nameValuePair2, ... nameValuePairN
Los pares de nombres (strings) y los valores (cualquier valor) donde los nombres son separados por una coma.
valor
Cualquier valor.

Description

El constructor Object crea una envoltura de objeto  al valor dado.  Si el valor es  {{jsxref("null")}} o {{jsxref("undefined")}}, creará y retornará un objeto vacío, de otra forma, retornará un objeto de un tipo que corresponda al valor dado. Si el valor ya es un objeto devolverá el valor.

Cuando es llamano en un contexto non-constructor, Object se comportará indenticamente a new Object().

Ver object initializer / literal syntax.

Propiedades del constructor Object

Object.length
Tiene un valor de 1.
{{jsxref("Object.prototype")}}
Permite añadir propiedades a todos los objetos del tipo Object.

Métodos del constructor  Object

{{jsxref("Object.assign()")}}
Copia los valores de todas sus propiedades enumerables desde uno o más objetos fuente a un objeto destino.
{{jsxref("Object.create()")}}
Crea un nuevo objeto con el prototipo objeto y propiedades específicadas.
{{jsxref("Object.defineProperty()")}}
Añade la propiedad nombrada descrita por un descriptor dado a un objeto.
{{jsxref("Object.defineProperties()")}}
Agrega las propiedades nombradas descritas por los descriptores dados a un objeto.
{{jsxref("Object.entries()")}}
Returns an array containing all of the [key, value] pairs of a given object's own enumerable string properties.
{{jsxref("Object.freeze()")}}
Freezes an object: other code can't delete or change any properties.
{{jsxref("Object.fromEntries()")}}
Returns a new object from an iterable of key-value pairs (reverses {{jsxref("Object.entries")}}).
{{jsxref("Object.getOwnPropertyDescriptor()")}}
Returns a property descriptor for a named property on an object.
{{jsxref("Object.getOwnPropertyDescriptors()")}}
Returns an object containing all own property descriptors for an object.
{{jsxref("Object.getOwnPropertyNames()")}}
Returns an array containing the names of all of the given object's own enumerable and non-enumerable properties.
{{jsxref("Object.getOwnPropertySymbols()")}}
Returns an array of all symbol properties found directly upon a given object.
{{jsxref("Object.getPrototypeOf()")}}
Returns the prototype of the specified object.
{{jsxref("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).
{{jsxref("Object.isExtensible()")}}
Determines if extending of an object is allowed.
{{jsxref("Object.isFrozen()")}}
Determines if an object was frozen.
{{jsxref("Object.isSealed()")}}
Determines if an object is sealed.
{{jsxref("Object.keys()")}}
Returns an array containing the names of all of the given object's own enumerable string properties.
{{jsxref("Object.preventExtensions()")}}
Prevents any extensions of an object.
{{jsxref("Object.seal()")}}
Prevents other code from deleting properties of an object.
{{jsxref("Object.setPrototypeOf()")}}
Sets the prototype (i.e., the internal [[Prototype]] property).
{{jsxref("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 {{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.

Properties

{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype', 'Properties') }}

Methods

{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype', 'Methods') }}

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 {{jsxref("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
{{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.

Browser compatibility

{{Compat("javascript.builtins.Object")}}

See also