"As long as the block of code inside the if fits in one line, you can also use this shorthand syntax (note the lack of curly brackets):"
My definition of "one line" invalidates this statement. However, I believe "one line" is pretty objective. Javascript will execute anything until it reaches a semi-colon. The following is valid Javascript.
if (foo)
for (i = 0; i < a.length; ++i)
if (i === 5)
console.log (a[i]);
Other than the obvious nitpicking, great article! It clears up a couple of confusing aspects of Javascript.
My definition of "one line" invalidates this statement. However, I believe "one line" is pretty objective. Javascript will execute anything until it reaches a semi-colon. The following is valid Javascript.
Other than the obvious nitpicking, great article! It clears up a couple of confusing aspects of Javascript.