CodesCompiler
πŸ”
HTMLCSSJavaScriptPythonSQLPHPSEOPostsBooksKids About Contact πŸš€ Get Started Free

JavaScript - ECMAScript 2016

JavaScript - ECMAScript 2016

TheECMAScript 2016version of JavaScript was released in 2016. Previously the old versions of JavaScript are named by numbers for example ES5 and ES6. Since 2016 the versions are named by the year they are released for example ECMAScript 2016, ECMAScript 17, etc. Lets discuss the featues added in ECMAScript 2016.

New Features Added in ECMAScript 2016

Here are the new methods, features, etc., added to the ECMAScript 2016 version of JavaScript.

  • Array includes() method
  • Exponentiation Operator (**)
  • Exponentiation Assignment Operator (**=)

Here, we have explained each feature in detail.

JavaScript Array includes() Method

The JavaScript array includes() methods is used to check whether the array contains a particular element.

Syntax

The syntax of Array includes() method in JavaScript is as follows βˆ’

JAVASCRIPT CODE
arr.include(searchElement, fromIndex);

Herearris the original array, thesearchElementis to be search from. The fromIndex is an optional argument if passed, the searching will start from thefromIndexindex.

Example

In the below code, we use the array includes() method to check whether the watches array contains the β€˜Noise’ brand.

Preview

Output

JAVASCRIPT CODE
Does watches array include Noise? true

Example

In the below code, we use the array includes() method to check whether the subjects array contains the β€˜Python’ subject searching from index 1.

Preview

Output

JAVASCRIPT CODE
Does subjects array include Python fromIndex 1? true

JavaScript Exponentiation Operator

The JavaScript exponentiation operator is used to find the power of the first operand raised to the second operand.

Syntax

The syntax of expponentiation operator is as follow βˆ’

JAVASCRIPT CODE
x ** y;

It returns the result of raising the first operand (x) to the power of the second operand (y).

Example

In the below code, we find the 22 using the exponentiation operator and store the resultant value in the β€˜res’ variable.

Preview

Output

JAVASCRIPT CODE
The resultant value for 2 ** 2 is: 4

Exponentiation Assignment Operator

The JavaScript exponentiation assignment operator raises the power of the first operand by the second operand and assigns it to the first operand.

Syntax

The syntax of exponentiation assignment operator is as follows βˆ’

JAVASCRIPT CODE
x **= y;

It assigns the result of raising the first operand (x) to the power of the second operand (y) to x.

Example

In the below code, we find the 102and assign the resultant value to the β€˜num’ variable using the exponentiation assignment operator.

Preview

Output

JAVASCRIPT CODE
The resultant value for 10 ** 2 is: 100

ECMAScript 2016 Browser Support

Most modern browsers support the ECMAScript 2016 version of JavaScript

ChromeFirefoxMicrosoft EdgeOperaSafariFirefox AndroidYesYesYesYesYesYes