why can't object literal call toString() method like {}.toString() cause error?

Viewed 642

When object literal calls toString() method like {}.toString() will cause syntax error, but when array literal call toString() it is OK. And when I assign the object literal to a variable, then when it call the toString() method will be OK. Why? For example:

var o = {};
o.toString();  // OK

{}.toString(); 
// > Uncaught SyntaxError: Unexpected token .
[1, 2, 3].toString(); // OK

Thanks!

1 Answers
Related