Free JavaScript reference · Python timeline
JavaScript ES2016: Small additions with useful edge cases
Exponentiation makes powers explicit, and includes supplies a membership test that can find NaN.
Edition 7 · Published · Editorial review October 26, 2026
Standardized in ES2016 · Syntax
Exponentiation with **
The ** operator raises one numeric value to a power. It gives a concise alternative to Math.pow for Number arithmetic. Powers associate from the right: 2 ** 3 ** 2 means 2 ** (3 ** 2).
Parentheses clarify a negative base. JavaScript rejects -2 ** 2 because a unary expression cannot be the unparenthesized left operand; (-2) ** 2 and -(2 ** 2) express different intentions.
Exponentiation is numeric calculation rather than a precision guarantee. Number arithmetic still uses floating-point representation.
Related context
const power = Math.pow(2, 3);
Context fragment; read it with the worked example.
Worked example
Uses ES2016 features · Script
console.log(2 ** 3); console.log(2 ** 3 ** 2); console.log((-2) ** 2, -(2 ** 2));
Expected output
8
512
4 -4
Example checked with Chromium 151.0.7922.34, Node.js 24.19.0.
Common mistake
Do not read a chain of powers left to right. Parenthesize negative bases instead of relying on an invalid unary-expression spelling.
Try it yourself
Compare (2 ** 3) ** 2 with 2 ** (3 ** 2) and explain why they differ.
Read more: ES2016 specification · MDN explanation and compatibility
Standardized in ES2016 · Built-in method
Array includes and NaN
includes returns a boolean membership result, which avoids treating a numeric index as a truthy or falsey answer. It uses SameValueZero comparison, so it can find NaN even though NaN is not strictly equal to itself.
The optional starting index controls where the search begins. Object values are still compared by identity rather than by their contents.
Use indexOf when you need an index and includes when you need membership. A successful match at index zero should not accidentally look like failure.
Worked example
Uses ES2016 features · Script
const values = [NaN, 2, 3]; console.log(values.includes(NaN)); console.log(values.indexOf(NaN)); console.log(values.includes(2, 2));
Expected output
true
-1
false
Example checked with Chromium 151.0.7922.34, Node.js 24.19.0.
Common mistake
Two object literals do not become equal because includes is used. Passing a starting index can intentionally skip an earlier match.
Try it yourself
Check whether [{id: 1}] includes a newly created {id: 1}. Then repeat with a saved reference to the same object.
Read more: ES2016 specification · MDN explanation and compatibility
Recap
Exponentiation makes powers explicit, and includes supplies a membership test that can find NaN. Check the engines your project supports before adopting new syntax or built-ins.
Read the ES2016 specification →