Skip to content

Instantly share code, notes, and snippets.

@vool
Created November 30, 2010 00:12
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 vool/720890 to your computer and use it in GitHub Desktop.
Save vool/720890 to your computer and use it in GitHub Desktop.
js ternary operators
/* js else if with ternary operators
* http://verens.com/2010/07/21/javascript-compression-tip/#comments
*/
function getValueFor(data){
return firstCondition(data)
?1
:secondCondition(data)
?2
:thirdCondition(data)
?3
:4;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment