Created
January 23, 2019 00:22
-
-
Save tegila/e68af3e582557ef3524590a670405c97 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
const func1 = (a, b, callback) => { | |
callback(a + b); | |
}; | |
const func2 = (a, b) => { | |
func1(a, b, result => { | |
console.log(result); | |
}); | |
}; | |
func2(19, 10); | |
func3 = (a, b) => { | |
return new Promise((resolve, reject) => { | |
try { | |
if (b <= 0) throw "assim nao dá"; | |
const c = a / b; | |
resolve(c); | |
} catch (e) { | |
reject(e); | |
} | |
}); | |
}; | |
func3(19, 0) | |
.then(console.log) | |
.catch(console.log) | |
.finally(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment