This can be achieved using the map
function.
var types = ["my", "misc", new Data].map(function (item) {
return typeof item;
});
However, I think this might be what you're looking for:
var types = ["my", "misc", new Data].map(function (item) {
var name = item.constructor && item.constructor.name;
return name? name: typeof item;
});
Please note that Function.name
is not standard and depending on the way you declared your functions, there might not be any reliable way to find the function's name.