I have a question about the reduce loop activity. Why it's not the same using array.length or a local variable? Array.length is not a method so why there will be less activity?
Because code needs to look for property every time for loop iterates and then send the property value, when you store the result of Array.length, it's just a number, your code doesn't need to look for anything, it can just pass the value.
That's why it faster, I am not sure if the speed difference matters that much. Probably not.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I have a question about the reduce loop activity. Why it's not the same using array.length or a local variable? Array.length is not a method so why there will be less activity?
Because code needs to look for property every time for loop iterates and then send the property value, when you store the result of Array.length, it's just a number, your code doesn't need to look for anything, it can just pass the value.
That's why it faster, I am not sure if the speed difference matters that much. Probably not.