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.

https://jsfiddle.net/npqgpcud/

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

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -