Object() constructor

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().


new Object()
new Object(value)


Any value.


Creating a new Object

let o = new Object()
o.foo = 42

// Object { foo: 42 }

Using Object given undefined and null types

The following examples store an empty Object object in o:

let o = new Object()
let o = new Object(undefined)
let o = new Object(null)


Browser compatibility

BCD tables only load in the browser

See also