JavaScript › Destructuring, Spread & Rest
How do you destructure properties out of an object?
BeginnerAnswer
Object destructuring pulls named properties into variables using curly-brace syntax; the variable names must match the property names unless you rename them.
const user = { name: 'Sam', age: 30 };
const { name, age } = user;
console.log(name); // 'Sam'Real-world example Extracting just the fields you need from a large API response object.