Skip to main content

ECMAScript

It is the standard that defines JavaScript, providing guidelines for its implementation and the syntax that modern JavaScript adheres to. It is the specification of scripting language which set rules.

Javascript first introduced in 1995 as LiveScript, but during development it called Mocha. But in the next year, in 1995 it changed to Javascript.

Key Features of ES6:

  • Arrow Functions
  • Classes
  • Template Literals
  • Destructuring Assignment
  • Default Parameters
  • Modules
  • Promises
  • Let and Const
  • Rest and Spread Operators

Features Introduced in ECMAScript 2025

  1. Enhanced Set Methods

    • Adds mathematical-style set operations: .union(), .intersection(), .difference(), .symmetricDifference()
    • Utility checks like .isSubsetOf(), .isSupersetOf(), and .isDisjointFrom().
  2. JSON Modules and Import Attributes

    • Support for JSON modules, allowing direct import of JSON files as modules.
    • Import attributes provide structured metadata alongside imports
  3. Promise.try() Utility

    • A convenient method that simplifies Promise chains, making it easier to start them without explicitly constructing a new Promise
  4. New Typed Array: Float16Array

    • Adds support for 16-bit floating-point numbers, useful for certain graphics or performance-sensitive applications

ECMAScript Versions

  1. ES1 (1997) – First edition, the foundation of JavaScript.
  2. ES2 (1998) – Editorial changes, aligned with ISO/IEC standards.
  3. ES3 (1999) – Big step: added try/catch, do-while, switch, regular expressions, etc.
  4. ES4 (abandoned, ~2000s) – Planned huge upgrade (classes, modules, types) but dropped due to complexity.
  5. ES5 (2009) – Major update:
    • strict mode ("use strict")
    • JSON support
    • Array.prototype methods (map, filter, reduce)
    • Object.create()
  6. ES5.1 (2011) – Minor alignment with ISO/IEC 16262:2011.
  7. ES6 / ES2015 (2015) – Huge milestone:
    • let / const
    • Arrow functions () => {}
    • Classes class Foo {}
    • Modules (import / export)
    • Template literals `Hello ${name}`
    • Promises
    • Map, Set, WeakMap, WeakSet
    • Spread/rest ...
    • Default parameters

Annual Releases (Year-based)

  • ES2016 (ES7) – Added Array.prototype.includes, exponentiation operator **.
  • ES2017 (ES8)async/await, Object.values, Object.entries, string padding.
  • ES2018 (ES9) – Rest/spread in objects, async iteration (for await...of).
  • ES2019 (ES10)Array.flat, Array.flatMap, Object.fromEntries, optional catch binding.
  • ES2020 (ES11)
    • BigInt (123n)
    • Nullish coalescing (??)
    • Optional chaining (?.)
    • Dynamic import (import())
    • Promise.allSettled()
  • ES2021 (ES12)
    • String.replaceAll
    • Logical assignment operators (||=, &&=, ??=)
    • WeakRefs
  • ES2022 (ES13)
    • Class fields & private methods (#field)
    • Top-level await in modules
    • Object.hasOwn()
  • ES2023 (ES14)
    • Array methods toSorted, toReversed, toSpliced, with()
    • Hashbang #! support
  • ES2024 (ES15)
    • RegExp /v flag
    • Set methods (union, intersection, etc.)
    • WeakMap/WeakSet metadata
  • ES2025 (ES16, upcoming) – Proposals in pipeline (like async disposable resources, pipeline operator |>, etc.)

Summary Rule

  • Pre-2015 → referred to as ES1–ES5.
  • 2015 → ES6 but officially renamed to ES2015.
  • After that → named after the year (ES2016, ES2017, …).

Deviates from ECMAScript

1. Web APIs (Not part of ECMAScript)

  • document, window, alert(), prompt(), confirm()
  • DOM APIs:
    • querySelector(), appendChild(), getElementById()
  • Network / async APIs:
    • fetch(), XMLHttpRequest, WebSocket
  • Storage:
    • localStorage, sessionStorage, indexedDB
  • Timers:
    • setTimeout(), setInterval()

These are defined by WHATWG (HTML spec) or W3C, not ECMAScript.

2. Host Objects / Environment Features

Node.js adds:

  • require(), module.exports
  • process, __dirname, __filename
  • File system APIs: fs, path, etc.

Deno / Bun add their own globals.

These are environment-specific, not part of ECMAScript.

3. Non-Standard / Legacy JavaScript Features

  • __proto__ property (originally non-ECMAScript, standardized later)
  • escape() / unescape() (deprecated)
  • arguments.callee (deprecated in strict mode)
  • Automatic semicolon insertion quirks (e.g., return on new line)
  • Octal literals with leading zero (0123) – legacy, now use 0o123

4. Error Handling Differences

  • Browsers sometimes throw different error messages or handle edge cases differently than the spec.
  • Example: function parameter shadowing rules in older IE vs ECMAScript spec.

5. Engine-Specific Extensions

  • V8 (Chrome / Node.js): sometimes implements experimental features behind flags before standardization.
  • SpiderMonkey (Firefox) and JavaScriptCore (Safari) may behave differently for in-progress proposals.

6. Global Objects Beyond ECMAScript

  • console.log() – widely used, but not in ECMAScript (part of WHATWG Console spec)
  • performance.now(), crypto.getRandomValues() – defined in Web APIs, not ECMAScript

Summary

  • ECMAScript = core language: syntax, types, operators, objects like Array, Object, Promise.
  • JavaScript = ECMAScript + Web APIs + host environment features.
  • Deviations mainly come from:
    • Browser APIs
    • Node.js APIs
    • Legacy quirks
    • Experimental engine features