jsguides

Reference

Object Methods

Static methods on the Object constructor.

  1. Object.assign()

    Object.assign() copies enumerable own properties from source objects into a target object and returns it. Covers merging, cloning, and defaults.

  2. Object.create()

    Object.create() creates a new object with a specified prototype and optional property descriptors for direct control over prototypal inheritance.

  3. Object.defineProperty()

    Object.defineProperty() lets you define or modify a property directly on an object with precise control over writability, enumerability, and configurability.

  4. Object.entries()

    Object.entries() returns an array of [key, value] pairs from an object's own enumerable properties, useful for iteration, filtering, and transformation.

  5. Object.freeze()

    Object.freeze() makes an object completely immutable, preventing new properties, deletions, and value changes. Returns the same object, not a copy.

  6. Object.fromEntries()

    Object.fromEntries() converts an iterable of key-value pairs into a plain object, useful for transforming Maps, Arrays, and URLSearchParams back to objects.

  7. Object.getPrototypeOf()

    Object.getPrototypeOf() returns an object's prototype — the value in its internal [[Prototype]] slot. Use it to inspect inheritance and verify object types.

  8. Object.hasOwn()

    Object.hasOwn() checks whether an object has a direct property without traversing the prototype chain — a safer alternative to hasOwnProperty().

  9. Object.is()

    Object.is() compares two values with special handling for NaN and signed zeros, treating NaN as equal to itself and distinguishing +0 from -0.

  10. Object.keys()

    Object.keys() returns an array of an object's own enumerable string-keyed property names. Learn how to iterate, count, and transform object keys in JavaScript.

  11. Object.seal()

    Object.seal() restricts an object by preventing new properties from being added or removed, while still allowing existing property values to be modified.

  12. Object.setPrototypeOf()

    Object.setPrototypeOf() mutates an object's [[Prototype]] to another object or null — a powerful but slow operation best avoided in performance-sensitive code.