javascript - Why does my Promise definition gets executed? -
i quite new promises , want know why promise definition gets executed without me calling .then()
or resolve on it.
var promise = new promise(function (resolve, reject) { console.log("starting loader"); resolve(); });
if run sample , see console see 'starting loader' message.
that how promises defined. run executor function immediately. it's in spec: promise(executor), step 10.
this instance of revealing constructor pattern; reading might understand.
Comments
Post a Comment