Skip to content

Instantly share code, notes, and snippets.

@msteckyefantis
Created January 10, 2017 17:13
Show Gist options
  • Save msteckyefantis/a348fa1a867c36e7eded8679aba5456e to your computer and use it in GitHub Desktop.
Save msteckyefantis/a348fa1a867c36e7eded8679aba5456e to your computer and use it in GitHub Desktop.
javascript lesson
'use strict';
const f = ( x, r ) => {
return Promise[ r ]( 2 * x )
.then( y => {
throw y;
},
z => {
throw z + 2;
})
.catch( w => {
console.log( w );
});
}
f( 3, 'resolve' );
// logs 6
f( 3, 'reject' );
// logs 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment