Day 1: Array & Object Destructuring
Daily Objective
Section titled “Daily Objective”Unpack properties and elements directly with ES6 destructuring syntax.
1. Destructuring Syntax
Section titled “1. Destructuring Syntax”// Object Destructuringconst user = { name: 'Elena', role: 'Developer', city: 'Madrid' };const { name, role } = user;
// Array Destructuringconst coordinates = [40.4168, -3.7038];const [latitude, longitude] = coordinates;Daily Hands-on Practice (70%)
Section titled “Daily Hands-on Practice (70%)”- Practice destructuring nested object properties.
- Swap two variables without a temporary variable using array destructuring:
[a, b] = [b, a].