'delay using promise instead of setTimeout [duplicate]
I know the output of the code but can anyone please tell me when setTimeout will be called please...
function delay(time) {
return new Promise(function (resolve) {
setTimeout(() => {
resolve();
}, time);
})
}
delay(3000).then(function () {
console.log("run after 3000 seconds")
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
