Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const bool = true;
- const returnBoolIfTrue = () =>
- new Promise(
- (resolve, reject) =>
- bool ? resolve(bool) : reject(new Error("dat shit ain't true"))
- );
- const logArg = arg => console.log(arg);
- //which do you prefer?
- //case 1
- returnBoolIfTrue().then(logArg);
- //case 2
- returnBoolIfTrue().then(result => logArg(result));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement