Promises from Scratch
- You can define your own Promises from scratch
- Can "wrap" asynchronous operations with a Promise
- Call a "resolve" function with the result of your operation (if any)
function delay(nMillis) {
return new Promise(function(resolve, reject) {
setTimeout(resolve, nMillis)
})
}
3 / 23