Skip to content

Instantly share code, notes, and snippets.

@kangax
Created December 9, 2009 04:37
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kangax/252265 to your computer and use it in GitHub Desktop.
/*
evaluates as a block — "{" and "}" — containing one labeled statement — `a:"a"`.
labeled statement, in its turn, evaluates to "a".
*/
{a:"a"}
/*
evaluates as an expression, where "(" and ")" are grouping operator and "{" and "}" constitute an object literal.
evaluates to this object value.
*/
({a:"a"})
/*
syntax error, `{a:"a",b:"b"}` is evaluated as a statement and statement can not have such syntax.
enforcing expression context — `({a:"a", b:"b"})` — fixes this "problem".
*/
{a:"a",b:"b"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment