Why does var o = {"a" : "b"}; executes and does what I expect, while eval('{"a": "b"}') fails?
<p>When I was fixing a bug in old code using evals, I realized something really weird about expression evaluation.</p>

<p>If you open a JavaScript console and type</p>

<pre><code>eval ('{"a": "b"}')
</code></pre>

<p>or </p>

<pre><code>{"a": "b"}
</code></pre>

<p>You get</p>

<pre><code>SyntaxError: Unexpected token :
</code></pre>

<p>But if you type </p>

<pre><code>var o = {"a": "b"};
</code></pre>

<p>The statement executes with the expectable result.</p>

<p>And also if you type</p>

<pre><code>(function() {return {"a": "b"};})()
</code></pre>

<p>You get:</p>

<pre><code>Object {a: "b"}
</code></pre>

<p>Also, if you type <code>{a: "b"}</code>, you get "b". I don't understand that at all.</p>

<p>I was used to think that <code>var o = {"a": "b"};</code> meaned "evaluate the expression <code>{"a": "b"}</code> and assign the result to <code>o</code>.</p>

<p>But apparently it's more complicated than that. I try to find the explanation on that point in the language specification, but I don't think I use the right wording to search.</p>

<p>Can anybody provide a clue about why I can return or assign the value of something that is not a valid evaluable expression by itself to a variable ?</p>
