javascript - native ES6 Promises in browser vs. Node (asynchrony) -


it looks es6 promises async default, without need use process.nexttick in node (unlike events instance).

e.g.:

promise.resolve('foo').then(function a() {     console.log('bar'); });  console.log('baz'); 

"baz" gets logged before "bar" appears async.

with node.js, internally accomplished via process.nexttick or not.

however, browser, how asynchrony achieved native promises? settimeout or other facility?

we can see async well:

new promise(function(resolve){      resolve('foo');  //called synchronously }).then(function(){      console.log('bar'); });  console.log('baz'); 

("baz" logged first)


Comments

Popular posts from this blog

ios - Memory not freeing up after popping viewcontroller using ARC -

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -