freecoding.school100% FREE · NO SIGNUP
Closure CavesISSUE #12 of 61

objects · key · value pairs

LambdaVSThe Mutator
Lambda saysObjects hold key–value pairs — the core structure for modeling things in JS.

{ name: "drew", age: 30 } groups related data. Access with dot (obj.name) or bracket (obj["name"], needed for dynamic or non-identifier keys). Objects are reference types: copying the variable copies the reference, not the data. Add, change, and delete properties freely.

Power-ups you unlock

The Mutator attacks — common mistakes

Boss battleBuild an object, read a property both ways, then add and delete a property.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>const u={name:'drew'}; u['role']='admin'; delete u.name;
document.getElementById('o').textContent=JSON.stringify(u);</script></body></html>
▶ Open the interactive comic issue
‹ Arguments · The Legacy Array-LikeObject Methods · Keys · Values · Entries ›