JavaScript

Leaving Curly Braces Out of JS If Statement

I spent so much time with Coffee that I constantly want to write this in Javascript:

return if x

Today I encountered with a new issue:

if (true) a = 1;
if (false) a = 2; a = 3;

What should a’s value be?

It’s 2. When we leave curly braces out of If Statements in Javascript, it only includes the first statement right after the condition brace. Careful there.

Standard