异步相关及事件循环
摘要:异步相关 script start 同步代码 async1 start 同步代码 async2 Promise是立即执行的,使用会先执行,这时console.log('async1 end')进入微任务中 promise1 Promise是立即执行的 这时console.log('promise2'
阅读全文
posted @
2019-02-20 23:39
西门本不吹雪
阅读(198)
推荐(0)
js的this对象相关
摘要:如果把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
西门本不吹雪
阅读(230)
推荐(0)
js数组扁平化
摘要:扁平化就是这样的: 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
西门本不吹雪
阅读(143)
推荐(0)
异步解决方案的发展历程
摘要:1. 回调函数(callback) 缺点:回调地狱,不能用 try catch 捕获错误,不能 return 回调地狱的根本问题在于: 缺乏顺序性: 回调地狱导致的调试困难,和大脑的思维方式不符; 嵌套函数存在耦合性,一旦有所改动,就会牵一发而动全身,即(控制反转); 嵌套函数过多的多话,很难处理错
阅读全文
posted @
2019-02-20 23:00
西门本不吹雪
阅读(209)
推荐(0)
javascript新增加的数据结构: Set Map WeakSet WeakMap
摘要:一、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
西门本不吹雪
阅读(236)
推荐(0)
JS数据类型总结及比较
摘要:js的基本数据类型:string,boolean,number,null,undefined,symbol(ES6) 引用数据类型:Object 判断基本数据类型:typeof ,需要注意的是null返回Object 判断引用类型:instanceof ,判断对象的原型 任何function 和 O
阅读全文
posted @
2019-02-20 21:15
西门本不吹雪
阅读(676)
推荐(0)