You have to wrap it in parens b/c JS treats toplevel curlies as a "block" rather than an object. But, of course, if you begin a line with parens, then it will become a function call on the previous line, if one exists, so for sanity's sake, begin any paren line with a semicolon (same for brackets).
Personally, I think it's really iffy to say that {} and [] are falsy values. I've always understood "falsy" to mean you can drop it into a conditional and it will behave like false would have:
You have to wrap it in parens b/c JS treats toplevel curlies as a "block" rather than an object. But, of course, if you begin a line with parens, then it will become a function call on the previous line, if one exists, so for sanity's sake, begin any paren line with a semicolon (same for brackets).
Personally, I think it's really iffy to say that
{}
and[]
are falsy values. I've always understood "falsy" to mean you can drop it into a conditional and it will behave likefalse
would have: