JavaScript Object Destructuring
This is a simple concept from ES6 that allows us the previledge of being picky as far as objects are concerned. Lets see an example that I used during my learning;
This is a simple concept from ES6 that allows us the previledge of being picky as far as objects are concerned. Lets see an example that I used during my learning;
const person = { img: "./images/your-image", name: "Mr. Oloyede Adeosun", phone: "(500) 777-1234", email: "email@email.com", };
So before I learnt that I could pick any item from the above object by writing something like this:
console.log(person.name) output = Mr. Oloyede Adeosun
But with destructuring, I can just pick what I need like this:
const { img, name} = person console.log(name) output = Mr. Oloyede Adeosun
Hope this helps someone out there. Happy Coding!!