Object Destructuring
What is Object?
Key-Value Pairs
const person = {
name: "Vignesh",
email: "[email protected]"
}How do we read the properties of above `object person` and store to another variable?
There are 2 common ways to do it
using dot notation
const name = person.name;
const email = person.email;using bracket notation
const name = person["name"];
const email = person["email"];But there is one simpler way to do this, i.e Object Destructuring.
const { name, email } = person;
// name -> person.name
// email -> person.emailVideo Link
Last updated