Scripter Javascript Tutorial
javascriptmusiclogicscripterbookexcerpttutorial9 Whitespace
MDN: Grammar and types: Basics
For the most part, whitespace is ignored in JavaScript except around reserved words. Whitespace can be used to help make code more readable, but there are particular uses which can’t be ignored.
var say_hi = "Hello, world!";
= "Hello, world!";
varsay_hi Trace(say_hi);
Trace( say_hi );
In the above example:
Line 1 will execute as expected.
Line 2 will throw an error because var is a reserved word in JavaScript. Scripter will think there is already a variable called
varsay_hi
which does not exist.Lines 3 and 4 are both valid and will execute as expected.