JavaScript Versions

  • This lesson covers the evolution and major versions of JavaScript.
  • Introduction to JavaScript Versions

    JavaScript has evolved continuously since its creation in 1995.
    To maintain consistency, compatibility, and standard behavior across browsers, JavaScript is standardized under ECMAScript.

    ECMAScript (ES) is the official standard that defines how JavaScript works.

    All JavaScript versions are actually ECMAScript versions.

    Why Do JavaScript Versions Exist ?

    Before standardization:

    • Browsers implemented JavaScript differently

    • Code worked in one browser but failed in another

    • No fixed rules or consistency

    To solve this:

    • JavaScript was standardized by ECMA International

    • Each update introduced a new ECMAScript version

    What is ECMAScript ?

    ECMAScript is:

    • A language specification

    • A set of rules and features

    • Followed by JavaScript engines

    JavaScript is the implementation of ECMAScript.
  • Timeline of JavaScript Versions
    ECMAScript VersionYearCommon Name
    ES11997First standard
    ES21998Minor updates
    ES31999Browser adoption
    ES52009Stable & widely used
    ES62015Major modern upgrade
    ES7+2016 onwardsYearly updates
  • Understanding ES5 (ECMAScript 5)

    What is ES5 ?

    ES5 is the most stable and widely supported version of JavaScript.
    It became the foundation of modern JavaScript development.

    Released in 2009, ES5 fixed many inconsistencies and improved reliability.

    Key Characteristics of ES5

    • Fully supported by all browsers

    • Simple syntax

    • No block scope

    • Function-based programming

    • Used in older projects

  • Important ES5 Features

    1. var Keyword

    var x = 10;

    var x = 20; // Allowed

    Problems with var:

    • No block scope

    • Hoisting issues

    • Can cause bugs

    2. Function Declaration

    function add(a, b) {

      return a + b;

    }

    3. Array Methods

    var numbers = [1, 2, 3];

    numbers.forEach(function(num) {

      console.log(num);

    });

    4. Strict Mode

    "use strict";

    x = 10; // Error (variable not declared)

    Improves code safety.

    Limitations of ES5

    • No let or const

    • No arrow functions

    • No classes

    • No modules

    • Verbose syntax

    Because of these limitations, a major update was required.

  • Introduction to ES6 (ECMAScript 2015)

    What is ES6 ?

    ES6 is the biggest and most important update in JavaScript history.

    Released in 2015, ES6 transformed JavaScript into a modern programming language.

    Why ES6 Was a Game Changer

    ES6:

    • Made JavaScript cleaner 

    • Reduced bugs

    • Improved readability

    • Enabled large-scale applications

    Major Features Introduced in ES6

    let and const (Block Scope)

    let x = 10;

    const y = 20;

    Difference:

    • let → value can change

    • const → value cannot change

    Block scope example:

    if (true) {

      let a = 5;

    }

    console.log(a); // Error

    Arrow Functions

    ES5:

    function multiply(a, b) {

      return a * b;

    }

    ES6:

    const multiply = (a, b) => a * b;

    Advantages:

    • Shorter syntax

    • Cleaner code

    • Better readability

    Template Literals

    ES5:

    var name = "Rahul";

    console.log("Hello " + name);

    ES6:

    let name = "Rahul";

    console.log(`Hello ${name}`);

    Classes

    ES5 (Function-based):

    function Person(name) {

      this.name = name;

    }

    ES6:

    class Person {

      constructor(name) {

        this.name = name;

      }

    }

    Default Parameters

    function greet(name = "User") {

      console.log("Hello " + name);

    }

    Destructuring

    const user = { name: "Amit", age: 25 };

    const { name, age } = user;

    Modules (import/export)

    export function add(a, b) {

      return a + b;

    }

    import { add } from "./math.js";

    ES6 Summary

    ES6 introduced:

    • Modern syntax

    • Safer variable handling

    • Object-oriented features

    • Modular programming

      ES7 and Beyond (ES6+)

      After ES6, JavaScript follows yearly updates.

      These versions are collectively called ES6+.

      Examples of ES6+ Features

      ES7 (2016)

      • includes()

      • Exponentiation operator

      console.log(2 ** 3); // 8

      ES8 (2017)

      • async / await

      async function fetchData() {

        let data = await fetch(url);

      }

      ES9+ (Modern JavaScript)

      • Spread operator

      • Rest parameters

      • Optional chaining

      • Nullish coalescing

      const user = { };

      console.log(user?.profile?.name);

    • ES5 vs ES6+ Comparison

      FeatureES5ES6+
      Variablesvarlet, const
      FunctionsRegularArrow
      ClassesNoYes
      ModulesNoYes
      ScopeFunctionBlock
      SyntaxVerboseClean

      Browser Support and Compatibility

      • ES5 → Supported everywhere

      • ES6+ → Supported in modern browsers

      • Older browsers may need transpilers (Babel)

      Which Version Should Beginners Learn ?

      Recommended order:

      1. ES5 basics (for understanding legacy code)

      2. ES6 features (main focus)

      3. ES6+ modern syntax

      Modern development uses ES6+ by default.

      Common Confusion

      • ES6 is not a different language

      • JavaScript did not replace ES5

      • ES6+ features are added, not removed