I want to learn more thoroughly how promises work in JavaScript and trying the next code:
function delay(timeout) {
return new Promise(function(resolve, reject){
setTimeout(resolve,timeout);
});
}
var promise = delay(10000);
promise.then(alert('after delay'));
I wanted to write a wrapper for JS setTimeout() function and I assume alert appearing after 10 sec while executing this code but it shows immediately, could someone explain what is wrong here?