JavaScript 2016
JavaScript Basics

JavaScript 2016

New Features in ECMAScript 2016

This chapter outlines the new features introduced in ECMAScript 2016:

  1. JavaScript Exponentiation (**)
  2. JavaScript Exponentiation Assignment (**=)
  3. JavaScript Array includes()

Browser Support

ECMAScript 2016 is fully supported in all modern browsers since March 2017:

  • Chrome 52 (July 2016)
  • Edge 15 (April 2017)
  • Firefox 52 (March 2017)
  • Safari 10.1 (May 2017)
  • Opera 39 (August 2016)

Note: ES 2016 is not supported in Internet Explorer.

Exponentiation Operator

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

Example:

let a = 4; let b = a ** 3;a ** b produces the same result as Math.pow(a, b):Example:javascriptCopy codelet a = 4; let b = Math.pow(a, 3);

Exponentiation Assignment

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

Example:

let a = 4; a **= 3;

The Exponentiation Operator is supported in all modern browsers since March 2017:

  • Chrome 52 (July 2016)
  • Edge 14 (August 2016)
  • Firefox 52 (March 2017)
  • Safari 10.1 (March 2017)
  • Opera 39 (August 2016)

JavaScript Array includes()

ECMAScript 2016 introduced the includes() method for arrays, allowing us to check if an element is present in an array.

Example:

const vegetables = ["Carrot", "Broccoli", "Spinach", "Peas"]; vegetables.includes("Spinach");

Array includes is supported in all modern browsers since August 2016:

  • Chrome 47 (December 2015)
  • Edge 14 (August 2016)
  • Firefox 43 (December 2015)
  • Safari 9 (October 2015)
  • Opera 34 (December 2015)

Take a look into your desired course