JavaScript (ES2026) reference · 19 entries

JavaScript Object Methods

The static Object methods: keys(), entries(), assign(), freeze(), groupBy() and more, with the ECMAScript edition that added each and runnable examples.

These are called on Object itself (Object.keys(user)), not on your objects. Most work only with an object's own properties, not inherited ones.

NameDescriptionSince
Object.assign() Copy all own enumerable properties from one or more source objects into a target object, and return the target. ES2015
Object.create() Create a new object with the given prototype (or null for an object with no inherited properties at all). ES5
Object.defineProperty() Add or change one property with full control over whether it is writable, enumerable and configurable, or define a getter. ES5
Object.defineProperties() Add or change several properties at once using property descriptors, each with its own writable and enumerable flags. ES5
Object.entries() Return an array of an object's own enumerable [key, value] pairs, ready for for…of loops or array methods. ES2017
Object.freeze() Make an object immutable: no properties can be added, removed or changed. The freeze is shallow. ES5
Object.fromEntries() Build an object from an iterable of [key, value] pairs, such as an array or a Map. The opposite of Object.entries(). ES2019
Object.getOwnPropertyDescriptor() Return the descriptor (value, writable, enumerable, configurable or get/set) of one own property. ES5
Object.getOwnPropertyNames() Return all own string property names, including non-enumerable ones that Object.keys() skips. ES5
Object.getPrototypeOf() Return the prototype of an object: the object it inherits methods and properties from, or null. ES5
Object.groupBy() Group the items of an iterable into an object whose keys come from a callback, e.g. orders grouped by status. ES2024
Object.hasOwn() Return true if an object has a property of its own (not inherited). The safer replacement for hasOwnProperty(). ES2022
Object.is() Compare two values like === but treat NaN as equal to NaN and +0 as different from -0. ES2015
Object.isFrozen() Return true if an object is frozen: no properties can be added, removed or changed. ES5
Object.isSealed() Return true if an object is sealed: properties can't be added or removed, but existing ones may still change. ES5
Object.keys() Return an array of an object's own enumerable property names, in insertion order (integer keys first). ES5
Object.seal() Prevent adding or removing properties while still allowing existing properties to be changed. ES5
Object.setPrototypeOf() Change the prototype of an existing object. It is slow in most engines; prefer Object.create() or classes. ES2015
Object.values() Return an array of an object's own enumerable property values, in the same order as Object.keys(). ES2017

Was this page helpful?