Is it costly to do array.length or list.count in a loop

前端 未结 6 649
梦谈多话
梦谈多话 2020-12-10 01:18

I know that in JavaScript, creating a for loop like this: for(int i = 0; i < arr.length; i++) is costly as it computes the array length each time. Is this be

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 02:03

    I believe if you use the Linq Count() extension method, then it may calculate every time it's called.

提交回复
热议问题