Guided Notes

Modern JavaScript (ES6+)

Destructuring, spread and rest, classes, optional chaining, modules, and iterators.

Destructuring

Slide 1 / 5

Destructuring unpacks values into variables in one step.

Arrays, by position: const [first, second] = ['gold', 'silver', 'bronze'];

Objects, by name: const { name, age } = user; const { name: fullName = 'Guest' } = user; // rename + default

In function parameters: function greet({ first, last }) { return `Hi ${first} ${last}`; }

Swap two variables: [a, b] = [b, a];

← Async JavaScript & Promises