-
Notifications
You must be signed in to change notification settings - Fork 0
Description
ES规范的每年一更新其实没有什么的价值
目前最新的ES2019已经发布了,你可以在这里找到:
http://www.ecma-international.org/publications/standards/Ecma-262.htm
由于历史的原因呢,JS开始于浏览器脚本,没有专门的标准库,所以一些常用的API都是让运行环境直接提供的。这导致了一个后果,那就是后来的ES规范把一些常用的API都直接写到语言规范中。
如果你看过Java语言规范,你就会发现Java语言规范写的很简洁,因为像什么集合类、各种Util类这些东西都是以标准库的方式提供的。Java语言规范并没有提及到它们。
而ES语言规范把大量的篇幅放到了什么Array对象上有什么方法、Map是干什么的这种事情上。从ES2015到ES2019,就是一些语法糖的更新,并没有什么本质的变化。
这是ES2019的一些新东西
This specification, the 10th edition, introduces a few new built-in functions: flat and flatMap on Array.prototype for flattening arrays, Object.fromEntries for directly turning the return value of Object.entries into a new Object, and trimStart and trimEnd on String.prototype as better-named alternatives to the widely implemented but non-standard String.prototype.trimLeft and trimRight built-ins. In addition, this specification includes a few minor updates to syntax and semantics. Updated syntax includes optional catch binding parameters and allowing U+2028 (LINE SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR) in string literals to align with JSON. Other updates include requiring that Array.prototype.sort be a stable sort, requiring that JSON.stringify return well-formed UTF-8 regardless of input, and clarifying Function.prototype.toString by requiring that it either return the corresponding original source text or a standard placeholder.
就是提供了几个新的API而已。
我觉得每年一个更新这个策略已经成为一个负担了,可能说对于ECMA委员会来说,每年不更新点什么会浑身难受。估计再过几年,ES规范的PDF版本能有几千页。
而且其实我个人是不建议开发者记忆太多的API。比如数组,你只要知道slice方法你就可以完成所有的相关的增删改。记得越多,忘得越多,到头来竹篮打水一场空。