Caffeinated Coder
Book an appointment
Lesson 12 · Working with data

Destructuring and spread

Destructuring unpacks values out of an object (by property name) or an array (by position) into separate variables in one line. Spread, written ..., does the opposite: it copies the items of an array or the properties of an object into a new one. Follow six real lines that unpack user and nums, collect the leftovers with ...rest, and build new arrays and objects without changing the originals.

9 min8 steps5 questionsBeginner
Fig 12 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.