ECMAScript 2016

JavaScript naming conventions started with ES1, ES2, ES3, ES5, and ES6.

However, ECMAScript 2016 and 2017 are not called ES7 and ES8.

Since 2016, new versions have been named by year (ECMAScript 2016/2017/2018).

New features in ECMAScript 2016

This chapter introduces the new features of ECMAScript 2016:

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

Exponentiation operator

Exponentiation operator (**) Raise the first operand to the power of the second operand.

Example

let x = 5;
let z = x ** 2;          // The result is: 25

Try It Yourself

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

Example

let x = 5;
let z = Math.pow(x, 2);   // The result is: 25

Try It Yourself

Exponentiation assignment

Exponentiation assignment operator (**=) Raise the value of the variable to the power of the right operand.

Example

let x = 5;
x **= 2; // The result is 25

Try It Yourself

Chrome 52 and Edge 14 are the first browsers to fully support the exponentiation operator:

Chrome IE Firefox Safari Opera
Chrome 52 Edge 14 Firefox 52 Safari 10.1 Opera 39
July 2016 August 2016 March 2017 March 2017 August 2016

JavaScript Array.includes()

ECMAScript 2016 will Array.prototype.includes Introduce array. This allows us to check if an element exists in the array:

Example

const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.includes("Mango"); // Returns true

Try It Yourself

All modern browsers support Array.prototype.includes:

Chrome IE Firefox Safari Opera
Chrome 47 Edge 14 Firefox 43 Safari 9 Opera 34
December 2015 August 2016 December 2015 October 2015 December 2015