Boolean shortcuts

Mike Samuel mikesamuel at gmail.com
Wed Jan 4 12:17:06 PST 2012


2012/1/4 Herby Vojčík <herby at mailbox.sk>:
> Hi,
>
> If you must think whether you should put it in
> parentheses or not to prevent runtime error, you rather write { window:false
> } and reduce the insecurity.

You already have to.

'boolean' === typeof eval('{ window: false }')


See section 12.4  :  http://es5.github.com/#x12.4
"""
12.4 Expression Statement # Ⓣ
Syntax
ExpressionStatement :
[lookahead ∉ {{, function}] Expression ;

NOTE An ExpressionStatement cannot start with an opening curly brace
because that might make it ambiguous with a Block.
"""


More information about the es-discuss mailing list