Question: why `<script> {'foo':'bar'}</script>` caused **Uncaught SyntaxError: Unexpected token :** at chrome 

and `<script> {foo:'bar'}</script>` just fine.

Answer: 
Because it's not an object literal, it's a code block. What's inside the brackets is not parsed as key-value pairs, it's parsed as code.

`foo: 'bar'` is fine as code, as `foo:` is a label and `'bar'` is an expression.

`'foo':` is not ok as code as a label can't be a string, it has to be an identifier.

To make it an object literal, you have to make it an expression, like:

```
<script> var x = {'foo':'bar'}</script>

```

or:

```
<script> ({'foo':'bar'})</script>

```
Note that this is not [JSON](http://json.org/), where you would need to use double-quotes (`"`).

As you are putting this object literal directly into a `<script>` element, it is not parsed as an [expression](https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Expressions_and_Operators) (where it would be a valid object). Instead, the braces are parsed as a [block](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/block) [statement](https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Statements), and `foo:` is parsed as a [label](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/label). `'foo'` would be an invalid label, therefore the Syntax Error.