1. Array.prototype.includes – Array method includes

The includes() method returns a Boolean value (true or false) based on whether an array contains a specific value or not. The array method includes has the following signature:

Copy to Clipboard

valueToFind

The value to search for. When comparing strings and characters, includes() is case-sensitive.

fromIndex | Optional

Optional parameter, default value is 0. This is the position in the array from where search starts. If fromIndex < 0, search starts at array.length + fromIndex .

Return Value – Boolean (true or false)

This method returns true if the value is found within the array, otherwise returns false.

Code Snippets

Copy to Clipboard

2. Exponentiation Operator (x**y)

The exponentiation operator ** is an ECMAScript proposal by Rick Waldron and available in ES7. This is an infix operator for exponentiation which produces the same result as Math.pow() .

Code Snippets

Copy to Clipboard

Let us look into a few more test cases

Copy to Clipboard

In special cases, say you want to find the result of -4 ** 3, you may end up getting SyntaxError if you try console.log(-4 ** 3);. Let us look into the below example:

Copy to Clipboard