In this section, we are going to learn efficient ways to create
for loops in detail.
How loops affect performance
Loops are a very common way to iterate through large blobs of data or objects and iterating through each instance of a DOM object or a piece of data. Let's say we have a simple loop that generates a
p paragraph tag and appends the page with an inner text value of the
i integer in the loop, with a maximum limit of
9000. Let's take a look at the following code sample and see how this is done. I've created a simple HTML5 page with a
script tag that includes the code on line 10, as shown next:
So, how is this code process-intensive? For ...