Browse JavaScript Topics ▼

Destructuring & Rest / Spread

📂 Objects & Arrays 📘 Lesson 11 of 23

Unpack values cleanly with object and array destructuring, and merge collections using the rest and spread operators (...).

Destructuring & Rest / Spread is an essential topic in JAVASCRIPT.

Overview

Mastering destructuring & rest / spread provides the core mental model and practical skills needed for modern frontend and backend full-stack engineering.

const user = { name: "Alan", role: "Admin", city: "London" };
// Destructure properties with defaults
const { name, role, country = "UK" } = user;

// Spread to shallow clone and override
const updatedUser = { ...user, city: "Manchester" };

// Rest parameters in function
function sumAll(...numbers) {
  return numbers.reduce((a, b) => a + b, 0);
}

Key Concepts

  • Understand the fundamental syntax, conventions, and mental model.
  • Avoid common traps, edge cases, and performance pitfalls.
  • Apply practical idioms directly in production applications.

[!TIP] Practice these core patterns thoroughly. Next, proceed to js-json-serialization.

Test your understanding of Destructuring & Rest / Spread

Quick interactive practice questions with instant feedback.

Take Quiz →