Why Does typeof Always Return Object In Sencha Touch?
Posted by admin on
October 5, 2012
When it came to a point where I had to use complex Javascript to handle objects, I had to use typeof to determine what kind of object it is.
I got confused at first why this certain variable that I used kept returning object. Further reading revealed that Javascript returns object for things which user may not consider to be objects like arrays.
Nulls also get a return value of object.
However, suppose your code already runs deep and you do not want to dig down your source codes just to check what type of object a variable is, you can use this line of code to determine the return type of the object.
Object.prototype.toString.call();
That should do the trick.
Donations appreciated. Every little $ helps. Or click Google +1. Or play the short video on the upper right of this page.









