Let's say I have a variable that could represent a number of different models (Objects). I want to respond to each differently, ideally through a switch
statement. Is it possible to get the instanceof
result as a value?
For example, something like this:
function determineModel(model) {
switch (model instanceof) { // this does not work
case 'Foo':
// do something
break;
case 'Bar':
// do something else
break;
default:
}
}