top of page

"They don't make bugs like Bunny anymore."

Performance Tip


When iterating through an array Don't set the condition to be less than array.length since that loads up the pressure on the program To avoid this, set a var equal to the array size Then make the condition in the for loop less than this var To explain it Imagine u have eggs in the fridge and u need a number of eggs for a dish or something U need to keep track of the number of eggs u have So u got two choices 1- u go every time to the fridge and count the number of eggs u have which is a useless extra work 2- u bring a note، write down the number of eggs u have and done u can always return to that note u took as a reference U saved urself the trouble of going to the fridge and counting the eggs u have Same thing with the for loop condition What u r doing is making the pc ask itself on each iteration to get the size of the array and compare if its greater than the counter index Which as a results causes an unnecessary performance loss

Featured Posts
Recent Posts
Archive
Search By Tags
No tags yet.
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page