const myObj = {
name: "Rahul",
age: 34,
Roll: 23
}
// console.log(myObj)
const {x, y, z} = myObj;
console.log(x)
I tried to store values of myObj in these three variables using the destructuring assignment but its giving undefined.
const myObj = {
name: "Rahul",
age: 34,
Roll: 23
}
// console.log(myObj)
const {x, y, z} = myObj;
console.log(x)
I tried to store values of myObj in these three variables using the destructuring assignment but its giving undefined.
You use destructuring assignment this way:
but if you want to rename the variables with
x,yandzyou can do this:Destructuring assignment