Promise
constructor to create a new promise.setTimeout()
to call the promise's resolve
function with the passed value
after the specified delay
.const resolveAfter = (value, delay) =>
new Promise(resolve => {
setTimeout(() => resolve(value, delay));
});
resolveAfter('Hello', 1000);
// Returns a promise that resolves to 'Hello' after 1s
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️