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

php - Hide output during test execution -

javascript - Migrate custom AngularJS filter from 1.2.28 to 1.4.x -

Update Magento products with multiple images -