Why is 'for(var item in list)' with arrays considered bad practice in JavaScript?

前端 未结 5 908
醉酒成梦
醉酒成梦 2020-11-27 12:47

Given a simple zero based, numerically indexed array:

var list = [\'Foo\', \'Bar\', \'Baz\'];

Many times, I have noticed that when someone

5条回答
  •  清歌不尽
    2020-11-27 13:28

    Speed?

    for(..;..;..) loop proved to be 36 times faster than for .. in when I tested it here.

    Link courtesy this SO answer

提交回复
热议问题