Skip to content

Instantly share code, notes, and snippets.

@ReeganExE
Last active January 19, 2019 04:08
Show Gist options
  • Save ReeganExE/012adc65f4ee57b03a0e99cfa73bfde4 to your computer and use it in GitHub Desktop.
Save ReeganExE/012adc65f4ee57b03a0e99cfa73bfde4 to your computer and use it in GitHub Desktop.
var p = Promise.reject('fack');
p.then(() => console.log('then1')).catch(() => console.log('catch1'));
p.catch(() => console.log('catch2'));
p.catch(() => console.log('catch3')).then(() => console.log('then3'));
p = p.then(() => console.log('then4')).catch(() => console.log('catch4'));
p = p.then(() => console.log('then5')).catch(() => console.log('catch5'));
// What will print?
var p = Promise.reject('rejected');
var log = text => () => console.log(text);
p.then (log('then1' )).catch(log('catch1'));
p.catch(log('catch2'));
p.catch(log('catch3')).then (log('then3'));
p = p.then (log('then4' )).catch(log('catch4'));
p = p.then (log('then5' )).catch(log('catch5'));
// What will print?
var p = Promise.reject('fack');
p.then(function() { console.log('then1'); }).catch(function() { console.log('catch1'); });
p.catch(function() { console.log('catch2'); });
p = p.then(function() { console.log('then3'); }).catch(function() { console.log('catch3'); });
p = p.then(function() { console.log('then4'); }).catch(function() { console.log('catch4'); });
// What will print?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment