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

前端 未结 6 650
梦谈多话
梦谈多话 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 01:50

    It will also depend on whether that getter is doing a calculation, or accessing a known value.

提交回复
热议问题