JS: ECMAScript 2016

By Xah Lee. Date: . Last updated: .

Array.prototype.includes

check if a value is in array. it can check for NaN, and empty elements in Sparse Array is treated as having values of undefined and you can check for it. (before, we have Array.prototype.indexOf but it cannot check for NaN, nor empty index in sparse array.)

Power operator: double asterisk **

new operator ** for power. this is better than Math.pow(x, y).

console.log(3 ** 2 === 9);
// true

Power assignment operator: double asterisk equal **=

let x = 3;
x **= 2;
console.log(x === 9);