Skip to content

Instantly share code, notes, and snippets.

@tilgovi
Forked from jhs/case.js
Created December 2, 2011 03:12
Show Gist options
  • Save tilgovi/1421563 to your computer and use it in GitHub Desktop.
Save tilgovi/1421563 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
? second_action()
: third_condition && can && (be || compound)
? (
can(),
abuse(),
commas(),
console.log("For fun")
)
: default_action()
@tilgovi
Copy link
Author

tilgovi commented Dec 2, 2011

See the comma operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment