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
for(int i = 0; i < arr.length; i++)
I believe if you use the Linq Count() extension method, then it may calculate every time it's called.