The NodeJS REPL evaluates code as an expression, by wrapping the code in parentheses, causing {"hello":1}
to be ({"hello":1})
which is parsed successfully as an object literal.
Usually and elsewhere (in Chrome/Firefox’s console), the curly braces are parsed as the delimiters of a block, like:
/*imagine if (true) */ {
"hello": 1 // <-- What's this syntax? It's meaningless.
}
{hello:1}
parses successfully, because hello
in this context has the meaning of a label:
/*imagine if (true) */ {
hello: 1;
} // ^-- Automatic Semicolon Insertion