for循环和for in 循环 for of循环的区别

    //for循环和for in 循环 for of循环的区别
    let array = [1, 2, 3, 4, 5];
    array.qqq = 123;
    for(let i = 0; i < array.length; i++){
        console.log(array[i]);//1, 2, 3, 4, 5
    }
    for(let k in array){//一般需要判断hasOwnProperty
        console.log(array[k]);//1, 2, 3, 4, 5, 123 
    }
    for(let value of array){
        console.log(value);//value是数组中的值  1,2,3,4,5
    }
原文地址:https://www.cnblogs.com/Lia-633/p/9913723.html