Skip to content

Instantly share code, notes, and snippets.

@jzaefferer
Created November 25, 2011 15:03
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 jzaefferer/1c7120d65487426f441c to your computer and use it in GitHub Desktop.
Save jzaefferer/1c7120d65487426f441c to your computer and use it in GitHub Desktop.
var switchObj = {
'alpha': function() {
// do X
},
'beta': function() {
// do Y
},
'_default': function() {
// do Z
}
};
(switchObj.hasOwnProperty(foo) && switchObj[foo] || switchObj._default)(args);
switch(foo) {
case 'alpha':
// do X
break;
case 'beta':
// do Y
break;
default:
// do Z
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment