JS 2016

JS Tutorial

JS Version

JS Objects

JS Function

JS Classes

JS Async

JS HTML DOM

JS Browser BOM

JS Web API

JS AJAX

JS JSON

JS vs JQUERY

JS Graphics

ECMAScript 2016

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

ECMAScript 2016 and 2017 was not called ES7 and ES8.

Since 2016 new versions are named by year (ECMAScript 2016 / 2017 / 2018).

New Features in ECMAScript 2016

There are new features that have been introduced 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

<!DOCTYPE html>

<html>

<body>

<h2>The ** Operator</h2>

<p id=”demo”></p>

<script>

let x = 5;

let z = x ** 2;

document.getElementById(“demo”).innerHTML = z;

</script>

</body>

</html>

Output

The ** Operator

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

Example

<!DOCTYPE html>

<html>

<body>

<h2>Math.pow()</h2>

<p id=”demo”></p>

<script>

let x = 5;

let z = Math.pow(x, 2)

document.getElementById(“demo”).innerHTML = z;

</script>

</body>

</html>

Output

Math.pow()

25

Exponentiation Assignment

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

Example

<!DOCTYPE html>

<html>

<body>

<h2>Exponentiation Assignment (**=)</h2>

<p id=”demo”></p>

<script>

let x = 5;

x **= 2;

document.getElementById(“demo”).innerHTML = x;

</script>

</body>

</html>

Output

Exponentiation Assignment (**=)

25