javascript
javascript
Destructuring in Javascript
Live
bolt
Level1
Progress0%

Destructuring in Javascript

CARD 1

Introduction

Login to report note issues for this section.

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.