ES7
1. includes
let array = [1, 2, 3]
if (array.includes(2)) {
console.log('array => have')
}
2. 运算符
console.log(2**3) // 8 => 2*2*2
ES8
1. entries :
a. 适用于数组和字符串
const obj=Object.entries('ab');
console.log(obj)//[["0","a"],["1","b"]]
const arr=Object.entries([1,2]);
console.dir(arr);//[["0","1"],["1","2"]]
b. 传入对象时,如果对象的键是数值类型时,会返回按键排序。如果对象的键是ASCII码值,则不会进行排序
const s1={
3 : 'a',
1 : 'b,
"xx": "22"
}
console.log(Object.entries(s1)) //[["1","b"],["3","a"],["xx","22"]]
c. 对象属性是Symbol类型时,即该属性无法被Object.entries遍历,注意Symbol类型用作对象的属性时必须带中括号[],不然就会被当做普通的字符串处理
d. 对象多个属性, 可根据entries循环,返回数据的每一个键值对
let data = {
a