15-07-2024 23:49
Status :
Tags : js
ECMAScript Specifications
ECMAScript (ES) is a scripting language specification standardized by ECMA International in ECMA-262 and ISO/IEC 16262. It is the standard upon which JavaScript is based. ECMAScript defines the core language features and constructs that JavaScript implements. Here’s an overview of what the ECMAScript specification entails:
-
Syntax and Semantics: ECMAScript specifies the syntax (rules for writing code) and semantics (meaning of the code). This includes rules for statements, expressions, keywords, and identifiers.
-
Types and Values: It defines the data types (e.g., Number, String, Object, Boolean, Null, Undefined, Symbol, BigInt) and the behavior of these types, including type conversion.
-
Objects and Properties: ECMAScript specifies the structure and behavior of objects, including object creation, property attributes, property descriptors, and the prototype chain.
-
Functions: It describes how functions are defined, invoked, and how they behave, including closures, arrow functions, and generators.
-
Control Abstractions: This includes control flow statements like loops (
for
,while
), conditional statements (if
,switch
), and exception handling (try
,catch
,throw
). -
Standard Library: ECMAScript provides a standard library of built-in objects and functions, such as
Array
,Date
,Math
,JSON
, and regular expressions. -
Modules: It defines the module system for organizing and reusing code, including how modules are defined, imported, and exported.
-
ECMAScript Versions: ECMAScript evolves through different editions. Key editions include:
- ES3 (1999): Introduced regular expressions, try/catch statements.
- ES5 (2009): Added strict mode, JSON support, and more array methods.
- ES6 (2015) (also known as ES2015 or ECMAScript 2015): Introduced classes, modules, arrow functions, template literals, and many new features.
- ES7 (2016) (ES2016): Added the exponentiation operator and
Array.prototype.includes
. - ES8 (2017) (ES2017): Introduced async functions,
Object.entries()
,Object.values()
, and more. - ES9 (2018) (ES2018): Added rest/spread properties, asynchronous iteration, and other features.
- ES10 (2019) (ES2019): Introduced
Array.prototype.flat()
,Array.prototype.flatMap()
,Object.fromEntries()
, and more. - ES11 (2020) (ES2020): Added
BigInt
,nullish coalescing operator
,optional chaining
, and more. - ES12 (2021) (ES2021): Added logical assignment operators, numeric separators, and other features.
The ECMAScript specification is continually updated to add new features and improve the language. It is essential for maintaining consistency and compatibility across different JavaScript engines and environments.