Skip to content

Day 1: Array & Object Destructuring

Unpack properties and elements directly with ES6 destructuring syntax.

// Object Destructuring
const user = { name: 'Elena', role: 'Developer', city: 'Madrid' };
const { name, role } = user;
// Array Destructuring
const coordinates = [40.4168, -3.7038];
const [latitude, longitude] = coordinates;
  1. Practice destructuring nested object properties.
  2. Swap two variables without a temporary variable using array destructuring: [a, b] = [b, a].