job-queue

What is the difference between “event loop queue” and “job queue”?

烈酒焚心 提交于 2019-11-27 08:03:56
I can not understand how the following code run. Why "1" is after "b" but "h" is after "3"? Should'n the order is: a, b, 1, 2, h, 3? Some article said that the difference between "event loop queue" and "job queue" leads to following output. But how? I have read the specification of ECMAScript 2015 - 8.4 Jobs and Job Queues , wanting to know how Promise'job works, but it makes me more confused. Can someone help me? Thank you! var promise = new Promise(function(resolve, reject) {resolve(1)}); promise.then(function(resolve) {console.log(1)}); console.log('a'); promise.then(function(resolve)

What is the difference between “event loop queue” and “job queue”?

ⅰ亾dé卋堺 提交于 2019-11-26 13:08:00
问题 I can not understand how the following code run. Why \"1\" is after \"b\" but \"h\" is after \"3\"? Should\'n the order is: a, b, 1, 2, h, 3? Some article said that the difference between \"event loop queue\" and \"job queue\" leads to following output. But how? I have read the specification of ECMAScript 2015 - 8.4 Jobs and Job Queues, wanting to know how Promise\'job works, but it makes me more confused. Can someone help me? Thank you! var promise = new Promise(function(resolve, reject)