javascript
Destructuring in JavascriptjavascriptLevel1
Progress0%
Contents
Destructuring in Javascript
1 / 10
Introduction
Destructuring
Destructuring is a syntax that allows you to unpack values from arrays or properties from objects into individual variables in a single, clean statement.
Without destructuring:
codejs
1const person = { name: "Arjun", age: 20, city: "Mumbai" };
2
3const name = person.name;
4const age = person.age;
5const city = person.city;With destructuring:
codejs
1const { name, age, city } = person;Same result — far less code. Destructuring is one of the most used ES6 features in modern JavaScript.