Zest.

JavaScript: Destructuring and spread

A short, tested JavaScript example for destructuring and spread. Copy it and adjust the names and paths for your project.

JavaScript
const { name, age = 18, ...rest } = person;
const [first, second, ...others] = list;

const copy = { ...person, age: 30 };
const merged = [...a, ...b];

Find it in Zest

Search for “javascript destructuring and spread” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More JavaScript examples

All JavaScript examples