1. Keys array
Object.keys returns an array of the object's own enumerable property names.
Object.keys(user)Typorithm · easy
Step 1 of 8 · intro card
Objects & Maps
Object.keys, Object.values, and Object.entries turn a plain object into iterable arrays. Object.entries pairs nicely with destructuring in map; merge objects with Object.assign({}, a, b) or spread { ...a, ...b }.
Plain objects are not directly iterable, so you bridge to arrays: Object.keys gives names, Object.values gives values, and Object.entries gives [key, value] pairs.
Object.entries(obj).map(([k, v]) => ...) destructures each pair, which is the idiomatic way to loop over an object's data.
To combine objects, Object.assign({}, a, b) copies sources into a fresh target, and the spread form { ...a, ...b } does the same more concisely — in both, later sources overwrite earlier keys.
Object.keys / values / entries expose object data as arrays.
Destructure entries with .map(([k, v]) => ...).
Merge with Object.assign({}, a, b) or { ...a, ...b }.
const user = { name: "Ada", age: 36, role: "admin" }
const keys = Object.keys(user)
const values = Object.values(user)
const pairs = Object.entries(user).map(([k, v]) => `${k}=${v}`)
const merged = Object.assign({}, user, { age: 37 })
const spread = { ...user, role: "editor" }Connect each part of the code to the concept before you type.
Object.keys returns an array of the object's own enumerable property names.
Object.keys(user)Object.values returns an array of the corresponding property values.
Object.values(user)Object.entries yields [key, value] pairs you can destructure inside map.
Object.entries(user).map(([k, v]) => `${k}=${v}`)Object.assign copies sources left to right into the target; later sources win.
Object.assign({}, user, { age: 37 })Spread copies own enumerable properties; later entries override earlier ones.
{ ...user, role: "editor" }Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.