Skip to content

Instantly share code, notes, and snippets.

@sofish
Created November 1, 2014 09:05
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sofish/c250881989aaa10c029d to your computer and use it in GitHub Desktop.
Save sofish/c250881989aaa10c029d to your computer and use it in GitHub Desktop.
Error
{"status":"error","error":{"msg":"\u6b64\u997f\u5355\u5df2\u6295\u8bc9","code":23}}
@maplejan
Copy link

maplejan commented Nov 1, 2014

主要是 JavaScript 中以「{」开头,会存在二义性。即,它有可能是一个 对象直接量,也可能是一个 语句块。ECMAS 的处理方式十分简单粗暴:在语法解析的时候,如果一个语句以「{」开头,就只把它解释成 语句块

只有为什么 {a:1} 没有错误,而 {"a":1} 却抛出异常。是因为解析器把 {a:1} 理解成了 标签,代码等同于:{ a: function () {} }

PS:对于这个问题,node 已经解决。

更详细的可以看这里:http://www.cnblogs.com/maplejan/p/3768010.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment