Is there any difference in terms of performance between those 2 cycles

Viewed 19

I wanted to know if there's any difference in terms of performance between these two cycles.

I already know they give the same result, but I always see both I'd like to know why does one get picked instead of another.

for (let i = 1; i <= 100; i++) {
   //
}


for (let i = 1; i < 101; i++) {
   //
}
1 Answers

No, there is no difference between i < 101 and i <= 100. Even if there was, it wouldn't be a difference you could detect.

Rather than worrying about any microoptimizations like this, concern yourself with which makes more sense to the human reader. If you're counting up to 100, then i <= 100 will make more sense to human readers.

Related