摘要:
js引擎有一个叫monitoring process,它用来检测主线程栈是否为空,不为空时,主线程任务依次执行,否则,将从Event table中拿到event queue 1.微任务在前,宏任务在后,并且队列也以顺序区分 2.微任务有:process.nexttick以及promise中的then 阅读全文
摘要:
function Observer(){this.fns = []} Observer.prototype = { subscribe:function(fn){ this.fns.push(fn) }, unsubscribe:function(fn){ this.fns = this.fns.f 阅读全文