📖 INDEX
LOADING ENGINE...
JS Destructuring
Clean up your code by extracting data like a pro.
destructuring.js⭐ 0 XP
📦
A.D.A: Destructuring is a JavaScript expression that allows unpacking values from arrays or properties from objects into distinct variables.
JS Progress
Master modern JavaScript syntax.
Object Destructuring
Imagine you have a config object. Before, you needed several lines to get its values. With destructuring, you do it in one:
const config = { theme: 'dark', fontSize: 16 };
// This is how it's done now:
const { theme, fontSize } = config;Key Concepts
Alias (Renaming)
You can assign a property to a variable with a different name using { property: newName }.
Default Values
If the property does not exist, you can define an initial value: { name = 'Guest' }.