2020年9月3日

generator生成器函数

摘要: generator生成器函数 定义: function后面加了* 函数体里有 yield关键字 1 2 3 4 5 function* Hello(name) { yield `hello${name}`; yield `how are you`; yield `bye`; } 表现形式 调用这个函 阅读全文

posted @ 2020-09-03 21:50 cx125 阅读(129) 评论(0) 推荐(0) 编辑

async/await语法

摘要: async/await语法 这是ES7的语法,它是基于generator函数做的语法(常用) 1 2 3 4 5 6 7 8 9 async function 函数名(){ let obj = await getName() return obj } 函数名().then(res=>{ //得到函数 阅读全文

posted @ 2020-09-03 21:48 cx125 阅读(108) 评论(0) 推荐(0) 编辑

set/weakset map/weakset

摘要: set/weakset map/weakset set用法 定义:是ES6的一种新的数据结构及(值的集合) Set跟其他数据结构不同的地方就在于:它的值不会有重复项。 (1)使用: 1 2 3 4 let set = new Set([13,3,4,5]) set.add(3)<br data-fi 阅读全文

posted @ 2020-09-03 21:41 cx125 阅读(114) 评论(0) 推荐(0) 编辑

es6类

摘要: ES6类 定义: 1 2 3 4 5 6 7 8 9 10 class Animal { //构造函数,创建这个类时会执行的函数 constructor(color){ //this当前对象 console.log("构造") this.color=color } } const myCat = n 阅读全文

posted @ 2020-09-03 21:37 cx125 阅读(127) 评论(0) 推荐(0) 编辑

ES6模块化

摘要: ES6模块化 创造原因:现在的web系统越来越庞大、复杂,需要团队分工,多人协作,大型系统的javascript文件经常存在复杂的依赖关系,后期的维护成本会越来越高。 JavaScript模块化正式为了解决这一需求而诞生。 环境配置: 目前浏览器不支持ES6模块化的语法,所以我们在node里进行测试 阅读全文

posted @ 2020-09-03 21:36 cx125 阅读(82) 评论(0) 推荐(0) 编辑

导航