for of遍历数组

废弃,没有for in好用

推荐使用for of遍历数组
    var myArray = [1, 2, 4, 5, 6, 7]
    myArray.name = "数组"
    for (var item of myArray) {
        console.log(item);
    }


面试题:
    var myArray = [1, 2, 4, 5, 6, 7]
    myArray.name = "数组"
    for (var i of myArray) {
        console.log(myArray[i]);
    }

你可能感兴趣的:(for of遍历数组)