I want to know the type of the variable put in the function. So, I used typeof
and like this:
randomFunctionName: function(obj){
switch(typeof obj){
case "object":
//Something
case "text":
//Something else
}
}
But the problem is, I can't tell if obj
is an array or an object, since
typeof [] === "object" //true
typeof {} === "object" //true
So, how I can I separate them? Is there any difference between them?