Favorites

JavaScript Object Object

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Object
JavaScript Fundamental · ConstructorThis object is supported by all modern browsers.
Updated 28th November 2026

Object is the base of almost every value in JavaScript. Plain objects store data as key-value pairs, and the Object constructor has static methods for copying, inspecting and freezing objects.

Description

The Object type represents a collection of properties: named values, which can be any type, including functions (then called methods). Nearly every value in JavaScript is an object or behaves like one, and all ordinary objects inherit from Object.prototype, which gives them methods such as hasOwnProperty() and toString().

Objects are usually created with an object literal, { name: 'Sam' }. The Object constructor itself is mostly used for its static methods: Object.keys(), Object.values() and Object.entries() list an object's contents, Object.assign() copies properties, Object.freeze() stops changes and Object.create() makes an object with a chosen prototype. For a collection whose keys aren't strings, or that changes often, a Map is often a better fit.

Every object has a prototype, another object it inherits properties from, forming the prototype chain that classes are built on. Property keys are always strings or symbols; other keys, such as numbers, are converted to strings. You can control how a property behaves, for example making it read-only or hidden from loops, with Object.defineProperty(), and stop an object from changing with Object.freeze() or Object.seal().

Creating

{ key: value, ... }
new Object()
Object.create(proto)

Static methods

NameDescription
Object.assign()The Object.assign() static method copies the properties of one or more source objects onto a target object and returns the target.
Object.create()The Object.create() static method creates a new object with a chosen prototype, which is useful for inheritance and for creating objects with no prototype at all.
Object.defineProperty()The Object.defineProperty() static method adds or changes a property with precise control over whether it can be changed, deleted or listed.
Object.entries()The Object.entries() static method returns an array of an object's [key, value] pairs, which makes it easy to loop over or transform an object.
Object.freeze()The Object.freeze() static method makes an object unchangeable: properties can't be added, removed or modified.
Object.fromEntries()The Object.fromEntries() static method builds an object from a list of [key, value] pairs, such as a Map or the result of Object.entries().
Object.getPrototypeOf()The Object.getPrototypeOf() static method returns the prototype of an object: the object it inherits properties from.
Object.groupBy()The Object.groupBy() static method sorts the items of an array or other iterable into groups, using a function that returns each item's group name.
Object.hasOwn()The Object.hasOwn() static method checks whether an object has a property of its own, as opposed to an inherited one.
Object.is()The Object.is() static method checks whether two values are the same, like === but treating NaN as equal to itself and +0 and -0 as different.
Object.isFrozen()The Object.isFrozen() static method checks whether an object is frozen, meaning it can't be changed at all.
Object.keys()The Object.keys() static method returns an array of an object's own property names.
Object.seal()The Object.seal() static method stops properties being added to or removed from an object, while still letting existing values change.
Object.values()The Object.values() static method returns an array of an object's property values.

Instance methods

NameDescription
Object.prototype.hasOwnProperty()The hasOwnProperty() method checks whether an object has a property of its own rather than an inherited one.
Object.prototype.toString()The toString() method returns a string representing an object.

Example

const user = { name: 'Sam', age: 30 };
user.email = 'sam@example.com';

console.log(Object.keys(user));
console.log(Object.entries(user));
console.log('age' in user);

const copy = { ...user, age: 31 };
console.log(copy.age, user.age);

Browser Support

The following information will show you the current browser support for the Object object. Hover over a browser icon to see the version that first introduced support for this object.

This object is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee