Why is lodash.each faster than native forEach?

前端 未结 4 2007
别跟我提以往
别跟我提以往 2020-12-04 14:16

I was trying to find the fastest way of running a for loop with its own scope. The three methods I compared were:

var a = \"t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t,t         


        
4条回答
  •  孤街浪徒
    2020-12-04 14:31

    Here's an updated link (circa 2015) showing the performance difference which compares all three, for(...), Array.forEach and _.each: https://jsperf.com/native-vs-underscore-vs-lodash

    Note: Put here since I didn't have enough points yet to comment on the accepted answer.

提交回复
热议问题