Last active
July 24, 2020 13:26
-
-
Save mishelashala/f6a2fbf077fc4b6f4aebd558125452da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Promise<number> | |
var promisedNumber = new Promise(function (fulfill, reject) { | |
setTimeout(() => { fulfill(10) }, 1000) | |
}); | |
// Promise<string> | |
var promisedString = new Promise(function (fulfill, reject) { | |
setTimeout(() => { fulfill('hello') }, 500) | |
}) | |
console.log('start') | |
promisedNumber.then( | |
// using arrow functions to "save" some visual space | |
(value) => { console.log('number: ', value) }, | |
(err) => { console.log('error: ', err.message) } | |
) | |
promisedString.then( | |
(value) => { console.log('string:', value) }, | |
(err) => { console.log('error:', err.message) } | |
) | |
console.log('finish') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment