[removed] confused about how nested for loops work

前端 未结 5 875
傲寒
傲寒 2020-12-17 02:49

Why do nested for loops work in the way that they do in the following example:

var times = [
            [\"04/11/10\", \"86kg\"], 
                     


        
5条回答
  •  南方客
    南方客 (楼主)
    2020-12-17 03:22

    You output would be appropriate if the log statement would read

    console.log(times[i][x]);
    

    Instead you output your complete new list newTimes which is initialized outside the inner loop and grows with each inner loop iteration.

提交回复
热议问题