Learn JavaScript
❯ objects.object_utilities

Object.keys/values/entries, assign & freeze in JavaScript

$concept

Static Object methods operate on objects wholesale: keys/values/entries return arrays of names, values, or [key, value] pairs (own string keys only — symbols need getOwnPropertySymbols); assign(target, ...sources) merges left-to-right mutating the target; freeze/seal/preventExtensions lock shapes with escalating strictness.

entries() plus for...of (or map/filter) turns objects into pipeline-friendly pairs and back via Object.fromEntries — the round trip powering object transforms. freeze is shallow (nested objects stay mutable) and silent outside strict mode.

$how it works
1

Enumerate as arrays

Object.keys/values/entries snapshot own string-keyed content into arrays for methods and loops.

2

assign merges left to right

Object.assign(target, a, b) copies into target (mutating it!) with later sources winning — spread usually reads better.

3

entries round-trips

Object.fromEntries(Object.entries(o).map(...)) transforms objects through pair pipelines.

4

Lock shapes deliberately

preventExtensions (no new keys), seal (+ no delete/reconfigure), freeze (+ no writes) — shallow locks, strict-mode loud.

$example
let scores = { a: 1, b: 2 };
console.log(Object.keys(scores).length);
let doubled = Object.fromEntries(
Object.entries(scores).map(([k, v]) => [k, v * 2]));
console.log(doubled.b);
Output
2
4
1keys() snapshots ["a", "b"] — length 2 counts fields.
2entries() pairs map to doubled values, fromEntries rebuilds the object.
3b doubled to 4 — object-wide transform through array methods.
$use cases
Iterating objects via keys/entries plus for...of
Transforming objects through entries-map-fromEntries pipelines
Merging configs (with spread preferred over assign)
Freezing constants and API surfaces against mutation

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in JavaScript yourself — building beats watching.