es7新特性
2018-03-21 10:01
369 查看
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属性
['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属性
相关文章推荐
- ES7、ES8新特性
- JavaScript ECMAScript 2015 (ES6) 和 ECMAScript 2016 (ES7) 新特性速查
- es7 新特性
- 从零开始学_JavaScript_系列(37)——让浏览器支持es7特性
- 聊聊ES7与ES8特性
- es7新增的2个特性
- ES7 新特性
- Scala中的语言特性是如何实现的(1)
- PHP 5.4 中的新特性
- JavaSE复习之十一 高级特性:反射和注释
- android 如何设置窗体特性getWindow().setFlags
- J2SE 5.0新特性 之 线程
- 看看Silverlight4有哪些新特性
- 面向对象三大特性
- MySQL事务的特性
- 优化网站设计(十四):使AJAX调用尽可能利用缓存特性
- MOS管和三极管开关特性
- Resumable可恢复特性(OCP试题)
- iOS 9 新特性之实现 3D Touch 就是 So easy -- OC版