默认分类

ECMA262 章节1

Introduction

介绍

This Ecma Standard defines the ECMAScript 2021 Language. It is the
twelfth edition of the ECMAScript Language Specification. Since
publication of the first edition in 1997, ECMAScript has grown to be
one of the world's most widely used general-purpose programming
languages. It is best known as the language embedded in web browsers
but has also been widely adopted for server and embedded applications.

ECMA定义了ECMAScript2021的语言。这是第12版ECMAScript语言规范。自从1997年发出的第一版,ECMAScript已经成长为世界上使用最广泛的通用编程语言之一。它以浏览器内嵌语言被熟知,并且也被服务器与嵌入APP广泛使用。

ECMAScript is based on several originating technologies, the most
well-known being JavaScript (Netscape) and JScript (Microsoft). The
language was invented by Brendan Eich at Netscape and first appeared
in that company's Navigator 2.0 browser. It has appeared in all
subsequent browsers from Netscape and in all browsers from Microsoft
starting with Internet Explorer 3.0.

ECMAScript 基于多个originating technologies,最令人熟悉的就是JavaScript (Netscape) 和 JScript (Microsoft) 。它由在网景 (Netscape) 的 Brendan Eich 发明并且首次在该公司的Navigator 2.0浏览器上出现。在来自网景的后续其他浏览器以及来自微软的IE 3.0浏览器之后的所有浏览器上都出现了它。

The development of the ECMAScript Language Specification started in
November 1996. The first edition of this Ecma Standard was adopted by
the Ecma General Assembly of June 1997.

ECMAScript 语言规范在 1996 年 11月 开始开发,第一版由 the Ecma General Assembly 在 1997 年 6 月发布。

That Ecma Standard was submitted to ISO/IEC JTC 1 for adoption under
the fast-track procedure, and approved as international standard
ISO/IEC 16262, in April 1998. The Ecma General Assembly of June 1998
approved the second edition of ECMA-262 to keep it fully aligned with
ISO/IEC 16262. Changes between the first and the second edition are
editorial in nature.
The third edition of the Standard introduced powerful regular
expressions, better string handling, new control statements, try/catch
exception handling, tighter definition of errors, formatting for
numeric output and minor changes in anticipation of future language
growth. The third edition of the ECMAScript standard was adopted by
the Ecma General Assembly of December 1999 and published as ISO/IEC
16262:2002 in June 2002.

该标准的第三版介绍了强大的正则表达式 (regular expressions) ,更好的字符串处理,new control statements,try/catch 异常处理,更严密的错误类型,数字类型格式化以及对语言未来成长的预期的小改动。ECMAScript 标准第三版在 1999 年 12 月 由 ECMA 大会推出并且作为 ISO/IEC 16262:2002 于 2002 年 6 月正式发布。

After publication of the third edition, ECMAScript achieved massive
adoption in conjunction with the World Wide Web where it has become
the programming language that is supported by essentially all web
browsers. Significant work was done to develop a fourth edition of
ECMAScript. However, that work was not completed and not published as
the fourth edition of ECMAScript but some of it was incorporated into
the development of the sixth edition.

第三版出版后,ECMAScript 与万维网一起实现了大规模采用,它已成为基本上所有 Web 浏览器支持的编程语言。为编制第四版ECMAScript做了大量工作。然而,这项工作尚未完成,也没有作为ECMAScript的第四版出版,但其中一些已纳入第六版的编写。

The fifth edition of ECMAScript (published as ECMA-262 5th edition)
codified de facto interpretations of the language specification that
have become common among browser implementations and added support for
new features that had emerged since the publication of the third
edition. Such features include accessor properties, reflective
creation and inspection of objects, program control of property
attributes, additional array manipulation functions, support for the
JSON object encoding format, and a strict mode that provides enhanced
error checking and program security. The fifth edition was adopted by
the Ecma General Assembly of December 2009.

ECMAScript第五版(作为ECMA-262第5版出版)编纂了对语言规范的实际解释,这些解释在浏览器实现中已司空见惯,并增加了自第三版出版以来出现的新功能的支持。这些功能包括访问器属性、对象的反射创建和检查、program control of property attributes、其他数组操作功能、对 JSON 对象编码格式的支持以及提供增强错误检查和程序安全性的严格模式。第五版于2009年12月由ECMA大会通过。

The fifth edition was submitted to ISO/IEC JTC 1 for adoption under
the fast-track procedure, and approved as international standard
ISO/IEC 16262:2011. Edition 5.1 of the ECMAScript Standard
incorporated minor corrections and is the same text as ISO/IEC
16262:2011. The 5.1 Edition was adopted by the Ecma General Assembly
of June 2011.

第五版已提交ISO/IEC JTC 1,根据the fast-track procedure通过,并批准为国际标准ISO/IEC 16262:2011。ECMAScript 标准第 5.1 版包含次要更正,与 ISO/IEC 16262:2011 文本相同。2011年6月,ECMA大会通过了5.1版。

Focused development of the sixth edition started in 2009, as the fifth
edition was being prepared for publication. However, this was preceded
by significant experimentation and language enhancement design efforts
dating to the publication of the third edition in 1999. In a very real
sense, the completion of the sixth edition is the culmination of a
fifteen year effort. The goals for this edition included providing
better support for large applications, library creation, and for use
of ECMAScript as a compilation target for other languages. Some of its
major enhancements included modules, class declarations, lexical block
scoping, iterators and generators, promises for asynchronous
programming, destructuring patterns, and proper tail calls. The
ECMAScript library of built-ins was expanded to support additional
data abstractions including maps, sets, and arrays of binary numeric
values as well as additional support for Unicode supplemental
characters in strings and regular expressions. The built-ins were also
made extensible via subclassing. The sixth edition provides the
foundation for regular, incremental language and library enhancements.
The sixth edition was adopted by the General Assembly of June 2015.

第六版的重点开发始于2009年,此时第五版正在编写出版。然而,在此之前,自1999年第三版出版之后,还进行了重大的实验和语言改进设计工作。从一个非常真实的意义上说,第六版的完成是十五年努力的高潮。本版的目标包括为大型应用程序提供更好的支持、库的创建以及 ECMAScript 作为其他语言的编译目标。它的一些主要增强功能包括模块、类声明、词法块范围、迭代器和生成器、异步编程的Promise、解构模式和正确的尾调用。内置的 ECMAScript 库已扩展以支持其他数据抽象,包括二进制数值的映射、集和数组,以及对字符串和正则表达式中的 Unicode 补充字符的其他支持。内置的也支持通过子类进行扩展。第六版为定期、增量语言和库增强提供了基础。大会于2015年6月通过了第六版。

ECMAScript 2016 was the first ECMAScript edition released under Ecma
TC39's new yearly release cadence and open development process. A
plain-text source document was built from the ECMAScript 2015 source
document to serve as the base for further development entirely on
GitHub. Over the year of this standard's development, hundreds of pull
requests and issues were filed representing thousands of bug fixes,
editorial fixes and other improvements. Additionally, numerous
software tools were developed to aid in this effort including
Ecmarkup, Ecmarkdown, and Grammarkdown. ES2016 also included support
for a new exponentiation operator and adds a new method to
Array.prototype called includes.

ECMAScript 2016 是 Ecma TC39 新的年度发布计划和开源开发流程下发布的首个 ECMAScript 版本。从 ECMAScript 2015 源文档构建了一个纯文本源文档,作为完全在 GitHub 上进一步发展的基础。在开发该标准的一年中,提交了数百个pr和issue,代表数千个错误修复、编辑修复和其他改进。此外,还开发了许多软件工具来帮助这项工作,包括 Ecmarkup、Ecmarkdown 和Grammarkdown。ES2016 还包括对新的指数运算符的支持,并将一种新方法添加到 Array.prototypeincludes

ECMAScript 2017 introduced Async Functions, Shared Memory, and Atomics
along with smaller language and library enhancements, bug fixes, and
editorial updates. Async functions improve the asynchronous
programming experience by providing syntax for promise-returning
functions. Shared Memory and Atomics introduce a new memory model that
allows multi-agent programs to communicate using atomic operations
that ensure a well-defined execution order even on parallel CPUs. It
also included new static methods on Object: Object.values,
Object.entries, and Object.getOwnPropertyDescriptors.

ECMAScript 2017 引入了 Async 函数、Shared Memory and Atomics,以及较小的语言和库增强功能、错误修复和编辑更新。异步函数通过提供返回Promise的函数的语法来改善异步编程体验。Shared Memory and Atomics引入了一种新的内存模型,允许多代理程序使用atomic 操作进行通信,即使在并行 CPU 上也能确保定义良好的执行顺序。它也包括Object上的新静态方法:Object.values, Object.entries, 和 Object.getOwnPropertyDescriptors.

ECMAScript 2018 introduced support for asynchronous iteration via the
AsyncIterator protocol and async generators. It also included four new
regular expression features: the dotAll flag, named capture groups,
Unicode property escapes, and look-behind assertions. Lastly it
included object rest and spread properties.

ECMAScript 2018 通过异步迭代器协议和异步生成器引入了对异步迭代的支持。它还包括四个新的正则表达式功能:dotAll 标志、命名捕获组、Unicode 属性转义和查找后方断言。最后,它包括对象rest和spread属性。

ECMAScript 2019 introduced 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, it
included a few minor updates to syntax and semantics. Updated syntax
included optional catch binding parameters and allowing U+2028 (LINE
SEPARATOR) and U+2029 (PARAGRAPH SEPARATOR) in string literals to
align with JSON. Other updates included 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.

ECMAScript 2019 引入了一些新的内置功能:Array 的原型方法 flat 和 flatMap 用于打平数组,Object.fromEntries 用于直接将 Object.entries 的返回值转换为新对象,位于 String.prototype 上的 trimStart 和 trimEnd 作为 better-named alternatives to the widely implemented 但是不标准的 String.prototype.trimLeft 和 trimRight 。 此外,它还包括一些语法和语义的次要更新。更新后的语法包括可选的 catch 绑定参数,并允许字符串文本中的 U+2028(LINE SEPARATOR) 和 U+2029(PARAGRAPH SEPARATOR)与 JSON 对齐。其他更新包括要求 Array.prototype.sort 是一个稳定的排序,要求 JSON.stringify 返回格式良好的 UTF-8,而不考虑输入,以及通过要求其返回相应的原始源文本或标准占位符来清晰定义Function.prototype.toString。

ECMAScript 2020, the 11th edition, introduces the matchAll method for
Strings, to produce an iterator for all match objects generated by a
global regular expression; import(), a syntax to asynchronously import
Modules with a dynamic specifier; BigInt, a new number primitive for
working with arbitrary precision integers; Promise.allSettled, a new
Promise combinator that does not short-circuit; globalThis, a
universal way to access the global this value; dedicated export * as
ns from 'module' syntax for use within modules; increased
standardization of for-in enumeration order; import.meta, a
host-populated object available in Modules that may contain contextual
information about the Module; as well as adding two new syntax
features to improve working with “nullish” values (null or undefined):
nullish coalescing, a value selection operator; and optional chaining,
a property access and function invocation operator that short-circuits
if the value to access/invoke is nullish.

ECMAScript 2020 是第 11 版,它引入了:

  • Strings 的 matchAll 方法,用于生成全局正则表达式生成的所有匹配对象的迭代器;
  • import(),一种语法,用于异步导入具有动态指定器的模块;
  • BigInt,一个新的数字基元,用于使用任意精度整数;
  • Promise.allSettled,一个新的不会发生短路的Promise;
  • globalThis,一种通用方式来访问全局的this;
  • 专用的export * as ns from 'module'语法,用于内置模块;提高枚举顺序的标准化;
  • import.meta,一个在模块中可用的主机填充对象,其中可能包含有关模块的上下文信息;
  • 以及添加两个新的语法功能,以改善使用"nullish"值(空或未定义):nullish coalescing,一个值选择运算符;
  • 可选链,一个属性访问和函数调用运算符,如果访问/调用的值为空,则短路。

Dozens of individuals representing many organizations have made very significant contributions within Ecma TC39 to the development of this edition and to the prior editions. In addition, a vibrant community has emerged supporting TC39's ECMAScript efforts. This community has reviewed numerous drafts, filed thousands of bug reports, performed implementation experiments, contributed test suites, and educated the world-wide developer community about ECMAScript. Unfortunately, it is impossible to identify and acknowledge every person and organization who has contributed to this effort.

代表许多组织的数十名个人在 Ecma TC39 中为本版和以前的版本的发展做出了非常重大的贡献。此外,一个充满活力的社区已经出现支持TC39的ECMAScript工作。该社区审阅了许多草稿,提交了数千份 Bug 报告,进行了实施实验,提供了测试套件,并教育了全球开发人员社区有关 ECMAScript。不幸的是,不可能查明和承认每一个为这一努力作出贡献的人和组织。

Allen Wirfs-Brock
ECMA-262, Project Editor, 6th Edition

Brian Terlson
ECMA-262, Project Editor, 7th through 10th Editions

Jordan Harband
ECMA-262, Project Editor, 10th through 12th Editions

回复

This is just a placeholder img.