Created
October 25, 2019 08:15
-
-
Save anushshukla/da36b8aff3e10fe3936da0d8cdbe2417 to your computer and use it in GitHub Desktop.
Promise and callback example
This file contains hidden or 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
| var promise = canReject => new Promise((resolve, reject) => canReject ? reject('bye') : resolve('hi')) | |
| const thenCallback = message => console.log(message); | |
| const catchCallback = message => console.log(message); | |
| promise() | |
| .then(thenCallback) | |
| .catch(catchCallback) | |
| promise(true) | |
| .then(thenCallback) | |
| .catch(catchCallback) | |
| var greet = callback => typeof callback === 'function' && callback('hi') | |
| var callback = prefix => prefix + ' Jai'; | |
| var greetJai = greet(callback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment