0
How to do property destructuring so that I can destructure name and age only
let a={ name:'alex', language:['java','c'], age:30} let {name,,age}=a Console.log(age) I am getting an error saying property destructuring pattern expected.
3 Answers
+ 6
Levi
Your code is right it has extra comma in second line bwt name and age
And in Console.log ...change it into console.log...
https://code.sololearn.com/cO67P5MIp4N8/?ref=app
It works...
+ 3
https://code.sololearn.com/cJ9C9nFuAAJa/?ref=app
In this code you can access language too
+ 2
possible destructuring:
let a={ name:'alex', language:['java','c'], age:30}
let {age,...others}=a
let {language,name}=others
let [x,y]=language
console.log(a)
console.log(age)
console.log(others)
console.log(language)
console.log(name)
console.log(x)
console.log(y)