Skip to content

Instantly share code, notes, and snippets.

@jzaefferer
Created Nov 25, 2011
Embed
What would you like to do?
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