Back to Cheat Sheets

Writing

JavaScript for Beginners Series - Part 7 (English & Darija)

Part 7 of the JavaScript for Beginners series by Ibtissam Oulahchoum. This guide covers essential ES6+ features: Destructuring (unpacking data) and the Spread Operator (expanding arrays/objects), with simplified explanations in Moroccan Darija.

JavaScript ES6 Destructuring Spread Operator Web Development Darija

January 23, 2026 · 2 min read

JavaScript for Beginners Series - Part 7 (English & Darija)

Introduction

Welcome to Part 7 of the JavaScript for Beginners Series. In this part, we explore two powerful features introduced in ES6 that make working with data cleaner and more efficient: Destructuring and the Spread Operator.

1. Destructuring (Assignment)

Destructuring is a syntax that allows you to "unpack" values from arrays or properties from objects into distinct variables. It reduces the need for repetitive code like person.name or person.age.

  • Darija: Destructuring هو واحد syntax ف javascript (ES6) لي كيخليك تجبد (extract) القيم من Array ولا properties و تحطهم بطريقة سهلة و نقية.

Code Example:

const user = {
  name: "Amine",
  age: 25,
  role: "Admin"
};

// OLD WAY
// const name = user.name;
// const role = user.role;

// MODERN WAY (Destructuring)
// We extract 'name' and 'role' directly
const { name, role } = user;

console.log(name); // "Amine"

2. The Spread Operator (...)

The Spread operator (...) allows an iterable (like an array) to be expanded. It is widely used to create copies of objects or merge them without mutating (changing) the original source.

  • Darija: Spread operator كيشد Array او Objet او كينشر المحتوى ديالو.

Code Example:

const numbers = [1, 2, 3];

// Merging arrays
const newNumbers = [...numbers, 4, 5];
// Result: [1, 2, 3, 4, 5]

// Updating Objects (Common in React)
// Copies all properties from 'user', but overwrites 'age'
const updatedUser = {
  ...user,
  age: 26
};

Related Cheat Sheets

Mentorship

Want to learn, not just read?

These cheat sheets are the short version. If you want the long one, I teach — one on one, at your pace, on what you are actually trying to build.

Let's talk
  • Learn with guidance

    I will walk you through the fundamentals, review your code, and help you grow past the tutorials.

  • Choose your career path

    Not sure which direction to take? We will talk it through and map a path that fits your strengths and your goals.

Want to work together?

I'm always open to discussing new projects.

Get in Touch