for..in loop loops over non-numeric indexes “clean” and “remove”

后端 未结 3 493
醉酒成梦
醉酒成梦 2021-01-29 10:10

This is something very basic I might be missing here but I haven\'t seen such result till now.

I have a for loop where options.headers.length is 3. And in

3条回答
  •  春和景丽
    2021-01-29 10:25

    if you don't want to iterate clean and remove then change the loop to:

    for (var i=0; i< options.headers.length;i++){
    //use i for getting the array data
    }
    

    if you use for (index in options.headers) it will iterate for non-numeric keys also.

提交回复
热议问题