Destructuring & Spread
Destructuring Assignment
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.
Array Destructuring
Object Destructuring
Spread Operator (...)
The spread operator (...) allows an iterable (like an
array) to be expanded in places where zero or more arguments or
elements are expected.
Rest Parameter (...)
The rest parameter syntax allows a function to accept an indefinite number of arguments as an array. It looks the same as spread, but is used in function definitions.
Summary
- Destructuring unpacks values from arrays or properties from objects into variables.
- The Spread operator (
...) expands iterables into elements. - The Rest parameter (
...) collects multiple elements into an array.
Quick Quiz
Which operator is used to unpack an array?
Enjoying these tutorials?