Em vez disso:
switch(x) {
case "First":
dosomething();
break;
case "first":
dontdosomething();
break;
case default:
dontdoanything();
break;
}
tente isto:
var switchAlternative = {
First: dosomething,
first: dontdosomething,
Switch: function(opt) {
var func = switchAlternative[opt];
if (typeof(func) == "undefined") {
return dontdoanything();
}
else {
return func[opt]();
}
}
}