If you want to print one property of object:
const object = {name:'vasia'};
const {name} = object;
console.log(`${name}`); // vasia
If you want to this property to be named differently (bio)
const object = {name:'vasia'};
const {name: bio} = object;
console.log(`${bio}`); // vasia
If this property is inside other property (person)
const object ={person: {name:'vasia'}};
const {person:{name}} = object;
console.log(`${name}`); // vasia
Hope this post will make me remember...
No comments:
Post a Comment