ES7 (ES2016)

exponentiation operator

a ** b 幂运算,与 Math.pow(a, b) 完全相同。

示例:

const a = 3, b = 3;

const exp = a ** b;

console.log(exp); // 27

Array.prototype.includes

判断一个数组是否包含一个指定的值,返回 true 或者 false

语法:

arr.includes(searchElement[, fromIndex])

  • searchElement 需要查找的元素值。

  • fromIndex 可选。从该索引处开始查找。如果为负值,则按升序从 array.length - fromIndex 的索引开始搜索。默认为 0

示例:

[1, 2, 3].includes(2);     // true
[1, 2, 3].includes(4);     // false
[1, 2, 3].includes(3, 3);  // false
[1, 2, 3].includes(3, -1); // true
[1, 2, NaN].includes(NaN); // true

results matching ""

    No results matching ""