当我尝试在for-of循环中获取索引时,它给出了错误:
VM343:60 Uncaught TypeError:undefined不是函数 在window.onload(VM343:60)
const items = [
{
id: 1,
name: 'asdffd'
},
{
id: 2,
name: 'asd3'
},
{
id: 3,
name: 'asdfsfsfdffd'
}
];
for (let [index,item] of items) {
console.log(item.name);
}
jsfiddle:http://jsfiddle.net/edwardtanguay/ob4t7ee9/
我需要什么语法来获取每次迭代的索引?