Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

Also, just saying even though this is pretty much general: 
1- Using array.length calculates the length of the array, and if you put it inside the parentheses of a for loop, it recalculates for nothing. As a small optimization, store the length in a variable, say, var length = array.length, and then, in the for loop, i < length. 

2- Instead of looping through indexes, you can use a for of loop if you aren’t using the value of ‘i’. 

For example: 

for (var item of array) {
console.log(item);
}
Of course, you don’t need to, but I feel like it’s something basic that many people don’t know, so I’m just posting it here.