The ES6 code snippet below is invalid. It used to be valid. I can still run it in old versions of Traceur but the latest Babel and Traceur don't seem to like the for-loop in an array anymore. Can anyone tell me why it's no longer valid.
let people = [
{
"firstName": "Belinda",
"phone": "1-607-194-5530",
"email": "[email protected]"
},
{
"firstName": "Elizabeth",
"phone": "1-155-446-1624",
"email": "[email protected]"
}
]
let phones = [for({phone} of people) phone];
console.log(phones)
The snippet below is valid ES6 so I know the destructing inside a for-loop is OK
for(let {phone} of people) {
console.log(phone)
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…