Created
January 10, 2017 17:13
-
-
Save msteckyefantis/a348fa1a867c36e7eded8679aba5456e to your computer and use it in GitHub Desktop.
javascript lesson
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
'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