First of all, absent other context:
{bar: 2}
does not create an object. It's a block statement with a single statement inside, and that statement has a label:
{
bar: // the label
2 // the expression statement
}
The text {bar: 2} is only an object when it appears in the context of an expression, like this:
foo({bar: 2}); // a function call to "foo", passing an object
Otherwise, a statement that begins with { is always interpreted as a block.
The statement
foo: {bar: 2}
is basically the same. Here, there's a label (foo:) outside the block, and a label (bar:) inside.
When you're trying code via a browser console, or Node, things get weird because the console itself has behavior intended to help with debugging but which is also different from language semantics in some cases. JavaScript is not directly a "REPL-friendly" syntax, so the console mechanism has to be clever.
consoleAPI with what the language actually does. Statements don't "return results" at all.