Skip to content

Instantly share code, notes, and snippets.

@jaredrada
Created April 16, 2013 23:31
Show Gist options
  • Select an option

  • Save jaredrada/5400546 to your computer and use it in GitHub Desktop.

Select an option

Save jaredrada/5400546 to your computer and use it in GitHub Desktop.
An alternative to the typical Javascript switch statement
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