-
-
Save jhs/1421621 to your computer and use it in GitHub Desktop.
A better case statement?
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
// Prettier case statement, but can also return a value since it is an expression. | |
// | |
first_condition | |
? first_action() | |
: second_condition | |
? function() { | |
var local_var = 'whatever' | |
second_action(local_var) | |
return whatever_else({you: "want"}) | |
}() | |
: third_condition && can && (be || compound) | |
? ( can() | |
, abuse() | |
, commas() | |
, console.log("For fun") | |
) | |
: default_action() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment