This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

  • 9.4 JS 2016

    • The JavaScript naming convention started with ES1, ES2, ES3, ES5 and ES6.
    • But, ECMAScript 2016 and 2017 was not called ES7 and ES8.
    • Since 2016 new versions are named by year (ECMAScript 2016, ECMAScript 2017).

    New Features in ECMAScript 2016

    This chapter introduces the new features in ECMAScript 2016

    • JavaScript Exponentiation (**)
    • JavaScript Exponentiation assignment (**=)
    • JavaScript Array.prototype.includes

    Exponentiation Operator

    The exponentiation operator (**) raises the first operand to the power of the second operand.

    Example 1: JS Exponentiation Operator
    let x = 5;
    let z = x ** 2;          // result is 25

    x ** y produces the same result as Math.pow(x, y):

    Example 2: JS Exponentiation Operator - Math.pow()
    let x = 5;
    let z = Math.pow(x,2);   // result is 25

    Exponentiation Assignment

    The exponentiation assignment operator (**=) raises the value of a variable to the power of the right operand.

    Example 3: JS Exponentiation Assignment (**=)
    let x = 5;
    x **= 2; // result 25

    Chrome 52 and Edge 14 was the first browsers to fully support the Exponentiation Operator:

    Chrome browser Edge browser Firefox browser Safari browser Opera browser
    Chrome 52 Edge 13 Firefox 52 Safari 10.1 Opera 39
    Jul 2016 Aug 2016 Mar 2017 Mar 2017 Aug 2016

    JavaScript Array.prototype.includes

    ECMAScript 2016 introduced Array.prototype.includes to arrays. This allows us to check if an element is present in an array:

    Example 4: JS Arrays - The includes() Method
    const fruits = ["Banana", "Orange", "Apple", "Mango"];
    
    fruits.includes("Mango"); // is true

    All modern browsers support Array.prototype.includes:

    Chrome browser Edge browser Firefox browser Safari browser Opera browser
    Chrome 47 Edge 14 Firefox 43 Safari 9 Opera 34
    Dec 2015 Aug 2016 Dec 2015 Oct 2015 Dec 2015
    Navigate this module

    Eventually the navigation links, above, will be replaced by these << (previous) and >> (next) buttons below.



    JavaScript icons used in the buttons provided by ICONS8.COM. Smartphone icons created by Freepik - Flaticon