Pilcrow Records

Scripter Javascript Tutorial

javascriptmusiclogicscripterbookexcerpttutorial

87 Use White Space

In a lot of code examples found on the Internet, the following format is used for brevity:

for (var i=0; i<array.length; i++) {
	var item=array[i];
}

That’s fine for simple, one-off examples. But for times when code is worked on for extended time frames and will likely be updated at some point in the future, the following is more readable:

for ( var i = 0 ; i < array.length ; i++ ) {
	var item = array[i];
}