Re:The Birth and Death of JavaScript [video]
by drostie on Friday April 18, 2014 @08:39AM
(#7608932)
It's because they wanted to say both:
and
which tends to make you think of curly braces as a syntactic feature which can appear anywhere, turning many lines of code into one line of code. If you think that way then these should possibly also be valid:
but, since JS scope is function-oriented and in other places (e.g. functions) the braces are ultimately needed anyways, even for one-liners, it seems like this was a stupid choice and we should have just rejected the form:
and then the reuse of {} for lightweight (if non-robust) hashmaps would perhaps be unambiguous again.
[ Parent
| on HN ]
Re:The Birth and Death of JavaScript [video]
by kbenson on Friday April 18, 2014 @09:52PM
(#7612243)
Which is exactly what Perl did, but to alleviate the clumsiness of single statement if conditionals they added a post-conditional if statement of the form STATEMENT if CONDITION; (which has the benefit of being how some people express simple conditionals in real life. "Go left if you see the blue house.")