Skip to content

Instantly share code, notes, and snippets.

@indongyoo
Last active April 3, 2018 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indongyoo/4b43fe2789426e60cc33161d1ae08f32 to your computer and use it in GitHub Desktop.
Save indongyoo/4b43fe2789426e60cc33161d1ae08f32 to your computer and use it in GitHub Desktop.
new Promise(function(resolve) {
setTimeout(function() {
resolve('hi');
}, 1000);
}).then(function(val) {
console.log(val); // 1초 뒤 hi
});
new Promise(function(resolve) {
setTimeout(function() {
resolve(Promise.reject('ho'));
}, 2000);
}).then(function(val) {
console.log(val); // 여기 오지 않음
}).catch(function(val) {
console.error(val); // 2초 뒤 ho
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment