3 ms·
Okay, putting all talk of practicality (interpreters, minifiers, convention) aside, let's look at the language itself for a bit; this could lead to some interes
by timknauf 18y ago
Okay, putting all talk of practicality (interpreters, minifiers, convention) aside, let's look at the language itself for a bit; this could lead to some interesting discussion.
JavaScript has two ways of designating the end of a statement. Here is (1):
;\n
And here is (2):
\n
Now, the semicolon can't help you if you type:
return\n
{a:1\n
b:2};\n
because statement end (2) has already kicked in, and so the code will return undefined.
So, given that statement end (2) is part of the standard (and doesn't look like leaving it anytime soon), is there any language reason to use statement end (1)? Is it purely a visual signifier? If so, is that useful to a majority of coders? Am I in a minority for considering it visual noise? Remember, we're putting aside practicalities like existing conventions, minifier capabilities and browser implementations for the sake of the exercise.