ES7中新增的语法指数运算以及includes

44 次浏览 1 分钟阅读 0 个喜欢

第一个是includes判断数组中的元素是否存在

let arr = ['hello', 'world']
console.log(arr.includes('hello')) // true
console.log(arr.includes('helle')) // false 

第二个是指数运算。ES7进行了简写

ES5中的做法

Math.pow(2, 2) // 4

ES7中的做法

2 ** 2 // 4