Skip to content

Instantly share code, notes, and snippets.

@jhs
Forked from tilgovi/case.js
Created December 2, 2011 03:37
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 jhs/1421621 to your computer and use it in GitHub Desktop.
Save jhs/1421621 to your computer and use it in GitHub Desktop.
A better case statement?
// 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