JavaScript

Destructuring in JavaScript

📅 December 05, 2025 ⏱️ 1 min read 👁️ 4 views 🏷️ JavaScript

Destructuring makes extracting values cleaner.

// Array destructuring
const [first, second, ...rest] = [1, 2, 3, 4, 5];

// Object destructuring  
const {name, age, city = 'NYC'} = user;

// Function parameters
function greet({name, age}) {
    console.log(`Hello ${name}, age ${age}`);
}

greet({name: 'Alice', age: 25});
🏷️ Tags:
javascript destructuring es6 syntax

📚 Related Articles