摘要: ES11语法新特性 私有属性 class Person { //公有属性 name; //私有属性 #age; #weight;//构造方法 constructor(name, age, weight) { this.name = name; this.#age = age; this.#weigh 阅读全文
posted @ 2022-03-18 20:56 苏槿年 阅读(48) 评论(0) 推荐(0) 编辑
摘要: ES10语法新特性 对象扩展方法Object.fromEnteries entries和fromEntries像是一个逆运算;一个是将对象转换为二维数组,一个是将二维数组转换为对象。 //二维数组 // const result = Object.fromEntries([ // ['name', 阅读全文
posted @ 2022-03-18 19:59 苏槿年 阅读(32) 评论(0) 推荐(0) 编辑
摘要: ES9语法新特性 对象展开 Rest 参数与spread扩展运算符在 ES6中已经引入,不过 ES6中只针对于数组,在 ES9中为对象提供了像数组一样的 rest参数和扩展运算符 对象的合并 // function connect({ host, port, ...user }) { // cons 阅读全文
posted @ 2022-03-18 19:26 苏槿年 阅读(20) 评论(0) 推荐(0) 编辑
摘要: ECMASript 8新特性 async 和 await async和 await两种语法结合可以让异步代码像同步代码一样 async函数 async函数的返回值为promise对象, promise对象的结果由async函数执行的返回值决定 //async 函数 async function fn 阅读全文
posted @ 2022-03-18 13:23 苏槿年 阅读(62) 评论(0) 推荐(0) 编辑
摘要: ECMASript 7新特性 Array.prototype.includes Includes 方法用来检测数组中是否包含某个元素,返回布尔类型值 //includes indexOf const mingzhu = ['西游记','红楼梦','三国演义','水浒传']; //判断 console 阅读全文
posted @ 2022-03-18 11:43 苏槿年 阅读(31) 评论(0) 推荐(0) 编辑