Beautiful for loop

Have a look at below code, where I am traversing the list of elements and doing some operation on it

with every increment in loop, we are checking i < elements.length. I can store elements.length in some variable, which increases the performance by caching the value of length.

Isn't it better. How about not using the extra variable and still achieve the same.

Wonder!, this is cool

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *