Objects Nested:
Objects are the backbone of JavaScript: they hold most data, configs, and
states. Mastering their manipulation is essential for writing clean, efficient, m
const co pany = { in o f : { na em : T h
' ec Corp', city : 'Paris' } }; const {
and bug-free code. Use this sheet to refresh key concepts quickly. in of : m
{ na e, city } } = co pany; m
Core Actions:
Spread & Rest :
Create:
Spread (copy/merge):
const user = { name: 'Alice', age: 25 };
const empty = [Link](null); // no prototype U
const new ser = { ...user, age : 28 };
Access: Rest (exclude props):
[Link]; // 'Alice' user
h
const { age, ...ot ers } = user;
['age']; // 25
const key = 'name';
user[key]; // 'Alice'
Utilities & Helpers:
Add / Modify / Delete:
v
Con ert to JSON / Parse JSON:
[Link] = 'Paris';
[Link] = 26;
const json = [Link](user);
delete [Link]; const parsed = [Link](json);
Check existence: Get prototype:
'age' in user; // true
[Link] (user); f
[Link]('age'); // true
Define properties:
Cloning & Merging: f
[Link] ineProperty(user, 'id', { value: 1, writable: false });
Shallow copy:
Check eq uality (reference-based):
const clone = { ...user };
const a = { x: 1 };
const copy = [Link]({}, user);
const b = { x: 1 };
a === b; // false (different refs)
Deep copy:
Compare deeply:
const deep = structuredClone(user);
[Link](a) === [Link](b); // true (simple deep check)
Merge:
onst merged = { ...user, country : 'FR' };
[Link](user, { verified: true }); Co mmon Patterns:
Defa ult values:
Inspect & Iterate: f
const con ig = { retries : 3, m
ti eout : 1000 };
f
const opts = { ...con ig, ...userOptions };
Keys / Values / Entries:
k
Object. eys(user); // ['name', 'age' ] [Link](user); // Optional chaining:
['Alice', 2 5] [Link](user); // [['name','Alice'], ['age',25]]
const city = [Link] .city ? ?? U k
' n nown';
Loop:
Dyna mic property names:
for (const key k [key]); }
in user) { [Link]( ey, user
f
[Link](user). or ac (( E h
[k, v]) => [Link](k, v)); for (const
const prop = 'role';
[k, v] of [Link](user)) { /* ... */ }
const obj = { [prop]: m
'ad in' };
Transform:
const upper = Object. ro f mEntries( m
[Link](user). ap(( [k, v]) => Pro Tips :
[[Link](), v]) );
Use structuredClone() for safe deep copies.
Destr ucturing : Avoid mutating objects passed as function params.
Extract values: For config merges, prefer f
{ ...de aults, ...o errides } v .
m
const { na e, age } = user;
Combine with arrays via [Link]() + map() magic.
Brought to you by Creators of the
Learn more at [Link]/javascript
Objects Nested:
Objects are the backbone of JavaScript: they hold most data, configs, and
states. Mastering their manipulation is essential for writing clean, efficient, m
const co pany = { in o f : { na em : T h
' ec Corp', city : 'Paris' } }; const {
and bug-free code. Use this sheet to refresh key concepts quickly. in of : m
{ na e, city } } = co pany; m
Core Actions:
Spread & Rest :
Create:
Spread (copy/merge):
const user = { name: 'Alice', age: 25 };
const empty = [Link](null); // no prototype U
const new ser = { ...user, age : 28 };
Access: Rest (exclude props):
[Link]; // 'Alice' user
h
const { age, ...ot ers } = user;
['age']; // 25
const key = 'name';
user[key]; // 'Alice'
Utilities & Helpers:
Add / Modify / Delete:
v
Con ert to JSON / Parse JSON:
[Link] = 'Paris';
[Link] = 26;
const json = [Link](user);
delete [Link]; const parsed = [Link](json);
Check existence: Get prototype:
'age' in user; // true
[Link] (user); f
[Link]('age'); // true
Define properties:
Cloning & Merging: f
[Link] ineProperty(user, 'id', { value: 1, writable: false });
Shallow copy:
Check eq uality (reference-based):
const clone = { ...user };
const a = { x: 1 };
const copy = [Link]({}, user);
const b = { x: 1 };
a === b; // false (different refs)
Deep copy:
Compare deeply:
const deep = structuredClone(user);
[Link](a) === [Link](b); // true (simple deep check)
Merge:
onst merged = { ...user, country : 'FR' };
[Link](user, { verified: true }); Co mmon Patterns:
Defa ult values:
Inspect & Iterate: f
const con ig = { retries : 3, m
ti eout : 1000 };
f
const opts = { ...con ig, ...userOptions };
Keys / Values / Entries:
k
Object. eys(user); // ['name', 'age' ] [Link](user); // Optional chaining:
['Alice', 2 5] [Link](user); // [['name','Alice'], ['age',25]]
const city = [Link] .city ? ?? U k
' n nown';
Loop:
Dyna mic property names:
for (const key k [key]); }
in user) { [Link]( ey, user
f
[Link](user). or ac (( E h
[k, v]) => [Link](k, v)); for (const
const prop = 'role';
[k, v] of [Link](user)) { /* ... */ }
const obj = { [prop]: m
'ad in' };
Transform:
const upper = Object. ro f mEntries( m
[Link](user). ap(( [k, v]) => Pro Tips :
[[Link](), v]) );
Use structuredClone() for safe deep copies.
Destr ucturing : Avoid mutating objects passed as function params.
Extract values: For config merges, prefer f
{ ...de aults, ...o errides } v .
m
const { na e, age } = user;
Combine with arrays via [Link]() + map() magic.
Brought to you by Creators of the
Learn more at [Link]/javascript