Skip to content

Instantly share code, notes, and snippets.

@image72
Created December 14, 2012 12:08
Show Gist options
  • Save image72/4285001 to your computer and use it in GitHub Desktop.
Save image72/4285001 to your computer and use it in GitHub Desktop.
switch case like this?
// switch case!
var add_level = {'5':1,'10':2,'12':3,'15':4}[12] || 0
//>>3
({'5':1,'10':2,'12':3,'15':4})[12] || 0
//>> 3
({'5':-1,'10':20.7e+5,'12':3,'15':"Right",'22':[4,1,16],'log':function() {console.log("that all right!")}})[12] || 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment