javascript - Return value of Promise's resolve/reject functions -


consider situation.

new promise(function(resolve, reject) {     var x = resolve(2); }); 

what value x be? tried print , showed me undefined. intuitive, so? in docs?

second question

new promise(function(resolve, reject) {     resolve(2);     return 5; }); 

what should return function put promise? value ignored?

the return value of promise constructor is ignored.

the resolve function returns undefined.

this first specified in promise constructor spec , later in es2015 (es6) language specification.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -