Created
April 16, 2013 23:31
-
-
Save jaredrada/5400546 to your computer and use it in GitHub Desktop.
An alternative to the typical Javascript switch statement
This file contains hidden or 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
| var manufacturer = { | |
| 'iPhone' : 'Apple', | |
| 'Windows 8' : 'Microsoft', | |
| 'Chrome' : 'Google', | |
| 'default' : 'Unknown manufacturer' | |
| } | |
| var who = manufacturer[device] || manufacturer['default']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment