es7新特性

1.Array.prototype.includes()方法,查找一个值在不在数组中,在就返回true,否则返回false
  ['a','b'].inclueds('a')//true
2.求幂运算符**
   3**2//9
3.异步函数:解决链式编程,让代码更简洁
   顺序处理多个异步结果
   async function asyncFunc() {
  const result1 = await otherAsyncFunc1();
  console.log(result1);
  const result2 = await otherAsyncFunc2();
  console.log(result2);
   }
   并行处理多个异步结果
   async function asyncFunc() {
  const [result1, result2] = await Promise.all([
    otherAsyncFunc1(),
    otherAsyncFunc2()
  ]);
  console.log(result1, result2);
  }
3.Object.entries()和Object.values()。获取具有键值对的数据结构的值,返回的数组顺序与for-in循环保持一致
   Object.entries({one:1,two:2})//[['one',1],['two',2]]
4.Object.getOwnPropertyDescriptors(obj,'id')返回目标对象中所有属性的属性描述符.第二个参数可选,第二个参数是获取指定属性的值。不包括从原型链继承来的。
    Object.assign()无法拷贝get属性和set属性,用Object.getOwnPropertyDescriptors配合Object.defineProperties可以实现正确拷贝set和get属性

猜你喜欢

转载自blog.csdn.net/xiaoxiaoluckylucky/article/details/79635595