Object Destructuring
I Have learnt the concept of object destructuring. I wish to share the same
Object destructuring is a feature in JavaScript that allows you to extract specific properties from an object and assign them to variables. It provides a convenient way to access object properties without having to repeat the object's name.
Here's an example of object destructuring:
// An example object
const person = {
firstName: 'John',
lastName: 'Doe',
age: 30,
email: 'john.doe@example.com'
};
// Object destructuring
const { firstName, lastName, age } = person;
// Now you can use the extracted properties as individual variables
console.log(firstName); // Output: John
console.log(lastName); // Output: Doe
console.log(age); // Output: 30