Object Destructuring in JavaScript
// Object Destructuring in JavaScript
// old style
// const bioData =
// {
// name: "abhishek",
// age: 28,
// deg: "Mca",
// hob: {
// first: "palying",
// sec: "Programming"
// }
// }
// console.log(`My name is ${bioData.name} `)
// New Style
// let {name:Myname,deg,age, hob} = bioData;
// console.log(`My name is ${Myname}. My age is ${age}. my qualification is ${deg}.
// i love ${hob.sec}`);
// 2020 style
const ReactNativeKing =
{
Laptop: "Macbook Air",
Programming: "JavaScript",
FrameWork: "ReactNative",
secFrameWork: "ReactJs",
Dream: {
Place: "switzerland",
Car: "RangeRover",
Person: "Elon Musk"
}
}
let {Laptop,Programming,FrameWork,secFrameWork, Dream} = ReactNativeKing;
console.log(`My Laptop is ${Laptop}. My favrite programming language is
${Programming}.my fav framework is ${FrameWork}.my secend framework is ${secFrameWork}.
I want to live this place called ${Dream.Place}. My dream car is ${Dream.Car}.
I like tech guy ${Dream.Person}`);
Comments
Post a Comment