【发布时间】:2009-04-17 19:43:39
【问题描述】:
EcmaScript 第五版或Ecma-262 已发布,其中包含对语言的一些更改。新版本中的哪些功能将帮助您编写更好的代码?
【问题讨论】:
标签: javascript ecma262 ecmascript-5
EcmaScript 第五版或Ecma-262 已发布,其中包含对语言的一些更改。新版本中的哪些功能将帮助您编写更好的代码?
【问题讨论】:
标签: javascript ecma262 ecmascript-5
第 15.12 节中的 JSON 对象看起来很棒。这会有所帮助,因为现在必须依赖不安全的 eval() 或一些缓慢的纯 JavaScript 实现,您必须将其包含在其余脚本中。没有原生支持,但这个新版本会有它。
【讨论】:
“严格”模式在介绍中听起来很有希望,但快速浏览一下附件 C(第 223 页)让我想知道它会有多大用处。
【讨论】:
很多 ES3.1 所做的实际上是定义已经存在的行为——比如for (... in ...) ... 语句中的枚举顺序。所以在某种程度上这些东西不会直接帮助你(除非出现一个新的 js 引擎)。
它还定义了一些新功能,例如
* prototype access -- i think through `getPrototype()` or something -- alas this isn't as powerful as `__proto__` present in JavaScriptCore and SpiderMonkey
* The JSON object to provide fast and safe JSON parsing rather than the conflagration of existing techniques
[编辑:回应抱怨 IE 的人——我相信 IE8 已经支持上述功能]
【讨论】:
很遗憾,完全没有,因为 IE 不支持任何超过五年左右的新标准。
【讨论】:
However, we expect that once it is finally approved, the revised ECMAScript standard to be widely and fairly rapidly adopted by browsers. In the meantime, this new specification is already having an impact. For example, in IE8 both the native JSON and the DOM Prototypes features are based upon APIs defined in the ECMAScript Fifth Edition Specification.。所以 ECMAScript 5 的一些特性已经在 IE8 中实现,期待更多(如果不是完整的实现)在 IE9 中。所以“绝对没有”似乎相当不准确。