Object Methods & Property Descriptors
Unlock the hidden configuration of objects. Learn how to iterate over keys, freeze data, and tweak invisible property flags.
The Object Utility Methods
Because objects aren't arrays, you can't just map() or filter() them directly. Instead, JavaScript provides static methods on the global Object class to extract their data into arrays.
Object.keys(obj) returns an array of the keys.
Object.values(obj) returns an array of the values.
Object.entries(obj) returns an array of [key, value] arrays, perfect for looping.
Freezing and Sealing
Sometimes you need to lock down an object to prevent other code from modifying it.
Object.freeze(obj) makes an object completely immutable. You cannot add, delete, or change any properties.
Object.seal(obj) is slightly less strict. You cannot add or delete properties, but you *can* still change the values of existing properties.
Property Descriptors
Under the hood, every property has hidden configuration flags called 'descriptors'. You can view them using Object.getOwnPropertyDescriptor(obj, 'key').
The flags are: writable (can the value change?), enumerable (will it show up in loops/keys?), and configurable (can it be deleted or have its flags changed?).
Descriptor Anatomy
Analyze how Object methods extract data, and see the hidden descriptor flags that power properties.
Descriptor Anatomy
Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
Object.keys(),values(), andentries()are the standard ways to extract data from objects into arrays.Object.freeze()makes an object completely immutable (shallowly).Object.seal()prevents adding/deleting keys, but allows updating existing values.- Property Descriptors hide flags like
writable,enumerable, andconfigurablebehind every property.
Done with this concept?
Mark it complete to track your progress. No login needed.