下面的ES6代碼片段無效。它曾經是有效的。我仍然可以在老版本的Traceur中運行它,但最新的Babel和Traceur似乎不再喜歡陣列中的for循環。誰能告訴我爲什麼它不再有效。ES6陣列解析不再有效嗎?
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)
以下代碼段是有效的ES6所以我知道自毀內部的for循環是OK
for(let {phone} of people) {
console.log(phone)
}
這是一個[陣列理解](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Array_comprehensions),它是從未在ES6降落的實驗建議/ ES2015 –