Why is looping through an Array so much faster than JavaScript's native `indexOf`?

后端 未结 7 1929
逝去的感伤
逝去的感伤 2020-11-29 03:15

Why is looping through an Array so much faster than JavaScript\'s native indexOf? Is there an error or something that I\'m not accounting for? I expected nati

7条回答
  •  盖世英雄少女心
    2020-11-29 04:01

    5 years from then, lot of changes happened in browsers. Now, indexOf performance has increased and is definitely better than any other custom alternative.

    Chrome Version 49.0.2623.87 (64-bit)

提交回复
热议问题