There are only two hard things in Computer Science: cache invalidation and naming thing...
There are only two hard things in Computer Science: cache invalidation and naming thing...
新增加的組件 表單元素和Vuex c-accordion 新使用的第三方組件 portal-vue vue-virtual-scroller preload-webpack-...
console.log('golb1');
setTimeout(function() {
console.log('timeout1');
new Promise(function(resolve) {
console.log('timeout1_promise');
resolve();
}).then(function() {
console.log('timeout1_then')
})
})
new Promise(function(resolve) {
console.log('glob1_promise');
resolve();
}).then(function() {
console.log('glob1_then')
})
setTimeout(function() {
console.log('timeout2');
new Promise(function(resolve) {
console.log('timeout2_promise');
resolve();
}).then(function() {
console.log('timeout2_then')
})
})
new Promise(function(resolve) {
console.log('glob2_promise');
resolve();
}).then(function() {
console.log('glob2_then')
})
對(duì)于這段代碼,瀏覽器和node 的執(zhí)行結(jié)果不一致,
瀏覽器的結(jié)果是:
timeout1->timeout1_promise->timeout1_then->timeout2->timeout2_promise->timeout2_then
而node結(jié)果是:
timeout1->timeout1_promise->timeout2->timeout2_promise->timeout1_then->timeout2_then
請(qǐng)問這是什么原因呢
前端基礎(chǔ)進(jìn)階(十四):深入核心,詳解事件循環(huán)機(jī)制JavaScript的學(xué)習(xí)零散而龐雜,很多時(shí)候我們學(xué)到了一些東西,但是卻沒辦法感受到進(jìn)步!甚至過了不久,就把學(xué)到的東西給忘了。為了解決自己的這個(gè)困擾,在學(xué)習(xí)的過程中,我一直在...
JavaScript的學(xué)習(xí)零散而龐雜,很多時(shí)候我們學(xué)到了一些東西,但是卻沒辦法感受到進(jìn)步!甚至過了不久,就把學(xué)到的東西給忘了。為了解決自己的這個(gè)困擾,在學(xué)習(xí)的過程中,我一直在...