2019年2月20日
摘要: 异步相关 script start 同步代码 async1 start 同步代码 async2 Promise是立即执行的,使用会先执行,这时console.log('async1 end')进入微任务中 promise1 Promise是立即执行的 这时console.log('promise2' 阅读全文
posted @ 2019-02-20 23:39 西门本不吹雪 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 如果把var scope= ‘globe’ 为 let scope = ‘globe’,结果就是 obj.lop(); // undefined: low obj.lop.call(obj); // undefined: low log.call(obj, 'create') // own: cre 阅读全文
posted @ 2019-02-20 23:32 西门本不吹雪 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 扁平化就是这样的: fun([1,2,[3,4]]) // [1,2,3,4] let a = [] console.log(a.concat(...[1, 2, 3, [4, 5]])) console.log(a.concat(...[1, [[2,55],9], 3, [4, 5]])) // 阅读全文
posted @ 2019-02-20 23:18 西门本不吹雪 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 1. 回调函数(callback) 缺点:回调地狱,不能用 try catch 捕获错误,不能 return 回调地狱的根本问题在于: 缺乏顺序性: 回调地狱导致的调试困难,和大脑的思维方式不符; 嵌套函数存在耦合性,一旦有所改动,就会牵一发而动全身,即(控制反转); 嵌套函数过多的多话,很难处理错 阅读全文
posted @ 2019-02-20 23:00 西门本不吹雪 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 一、Set ES6提供新的数据结构Set,类似于Array,不过Array中的值可以重复,但是Set中的值不可以重复 声明: Set函数是一个构造函数 let set = new Set([1,2,3,2]) console.log((new Set([1,2,3,2])).size) // 3 c 阅读全文
posted @ 2019-02-20 22:54 西门本不吹雪 阅读(214) 评论(0) 推荐(0) 编辑
摘要: js的基本数据类型:string,boolean,number,null,undefined,symbol(ES6) 引用数据类型:Object 判断基本数据类型:typeof ,需要注意的是null返回Object 判断引用类型:instanceof ,判断对象的原型 任何function 和 O 阅读全文
posted @ 2019-02-20 21:15 西门本不吹雪 阅读(662) 评论(0) 推荐(0) 编辑