ES7 (ECMAScript 2016) introduced the exponentiation operator and Array.prototype.includes method, providing more convenient ways to work with numbers and arrays.
June 2016
ES7 (ECMAScript 2016) introduced the exponentiation operator and Array.prototype.includes method, providing more convenient ways to work with numbers and arrays.
Try out JavaScript code examples and experiment with features in the official TypeScript playground.
Open JavaScript PlaygroundRaises the left operand to the power of the right operand.
const result = 2 ** 3; // 8
const square = 5 ** 2; // 25
// Equivalent to Math.pow
const same = Math.pow(2, 3); // 8Determines whether an array includes a certain value among its entries.
const numbers = [1, 2, 3, 4, 5];
console.log(numbers.includes(3)); // true
console.log(numbers.includes(6)); // false
// With start index
console.log(numbers.includes(2, 2)); // false (starts from index 2)