The typeof operator is used in either of the following ways:
The typeof operator returns a string indicating the type of the unevaluated operand. operand is the string, variable, keyword, or object for which the type is to be returned. The parentheses are optional.
Suppose you define the following variables:
The typeof operator returns these results:
typeof myFun is object typeof shape is string typeof size is number typeof today is object typeof dontExist is undefined
For the keywords true and null, the typeof operator returns these results:
For a number or string, the typeof operator returns these results:
For property values, the typeof operator returns the type of value the property contains:
For methods and functions, the typeof operator returns results as follows:
typeof blur is function typeof eval is function typeof parseInt is function typeof shape.split is function
For predefined objects, the typeof operator returns results as follows: