JavaScript Object Functions
JavaScript Object Functions
Object.values()
Extracts all values from an object and returns
them as an array.
Object.entries()
Converts the object into an array of [key, value]
pairs. Useful for iterating over both keys and
values.
Object.fromEntries()
Converts an array of [key, value] pairs back into
an object.
Object.assign()
Copies properties from source objects into a
target object. Often used for shallow cloning or
merging objects.
Object.freeze()
Makes an object immutable, meaning you can’t
add, remove, or change its properties.
Object.seal()
Prevents adding or removing properties but
allows modifications to existing ones.
Object.hasOwn()
Checks if the object has a specified property
directly, ignoring inherited properties.
Object.is()
Compares two values to check if they are the
same. Fixes edge cases where === fails (e.g., NaN).
Object.getOwnPropertyDescriptors()
Returns detailed metadata about an object’s
properties, such as value, writable, and
enumerable.
🌟 Advanced Use Cases
Combine these functions for powerful
workflows: