JavaScript » Special » typeof

The typeof operator returns the type of an unevaluated operand which can be a number, string, variable, object or keyword.

It can be used with or without brackets as in the following examples of a numeric literal and the variable 'age' being 60:
typeof(age)   returns    number
typeof 33   returns    number
The following values are returned for various types of data:
a number returns 'number';
a string returns 'string';
the keyword true returns 'boolean';
the keyword null returns 'object';
methods, functions and predefined objects return 'function';
a variable returns the type of the data assigned to it;
a property returns the type of its value;

See Also: