Given these four examples of defining an object and then attempting to immediately access their properties:
{foo: \'bar\'}.foo
// syntax error: unexpected_to
It's a matter of the "context", your first two examples are not object literals!
They are statement blocks, for example:
{ foo: 'bar' }
The above code is evaluated as a block, containing a labelled statement (foo) that points to an expression statement (the string literal 'bar').
When you wrap it on parentheses, the code is evaluated in expression context, so the grammar matches with the Object Literal syntax.
In fact there are other ways to force the expression evaluation, and you will see that the dot property accesor notation works when applied directly to an object literal e.g.:
({foo:'bar'}.foo); // 'bar'
0, {foo:'bar'}.foo; // 'bar'
0||{foo:'bar'}.foo; // 'bar'
1&&{foo:'bar'}.foo; // 'bar'
// etc...
Now in your second example:
{foo: 'bar'}['foo']
What happens here is that the two statements are evaluated, first the block and then the expression statement that contains the Array literal.
Is a syntax ambiguity similar to what happens with function expressions vs function declarations.
See also: