Skip to main content


typeof is the 'official' function that one uses to get the type in JavaScript, however in certain cases it might yield some unexpected results ...

1. Strings

typeof "String" or typeof Date(2011,01,01)


2. Numbers typeof 42


3. Bool

typeof true (valid values true and false)


4. Object typeof {} or typeof [] or typeof null or typeof /aaa/ or typeof Error()


5. Function

typeof function(){}


6. Undefined

var var1; typeof var1