Javascript for..in vs for loop performance

前端 未结 4 673
忘了有多久
忘了有多久 2020-11-30 11:36

I was clustering around 40000 points using kmean algorithm. In the first version of the program I wrote the euclidean distance function like this

var euclide         


        
4条回答
  •  渐次进展
    2020-11-30 12:08

    First You should be aware of this in the case of for/in and arrays. No big deal if You know what You are doing.

    I run some very simple tests to show the difference in performance between different loops: http://jsben.ch/#/BQhED

    That is why prefer to use classic for loop for arrays.

提交回复
热议问题