ECMAScript 2016 (7)
特性一览
幂运算
Exponentiation Operator: **
返回第一个操作数取第二个操作数的幂的结果。它等价于 Math.pow(),不同之处在于,它还接受 BigInt 作为操作数。
js
3 ** 4; // 81
10 ** -2; //0.01
2 ** (3 ** 2); //512
(2 ** 3) ** 2; //64
幂赋值运算
JavaScript Exponentiation assignment: **=
将左侧变量的值设置为右操作数的幂次方
js
let a = 5;
a **= 2; //25
数组的 includes()
判断一个数组是否包含一个指定的值
js
const arr = [1, 2, 3];
arr.includes(2); // true