Destructuring assignment is a convenient way to extract values from arrays or objects and assign them to variables. It can be used with arrays, objects, and even nested structures.
Example with array:
let [x, y] = [1, 2];
console.log(x, y); // Output: 1 2
Example with object:
let { name, age } = { name: 'John', age: 30 };
console.log(name, age); // Output: John 30
Tags: intermediate, JavaScript, Destructuring
URL: https://www.tiktok.com/@jsmentoring/photo/7470674451730910486