typeof
typeof — Check the type of a variable.
Description
typeof mixed variable
Parameters
Name |
Description |
Type |
Default |
Optional |
variable |
The variable to get the type of. |
mixed |
|
No |
Return values
string - A string indicating the variable type.
Examples
Example #1 – typeof example
var b = new Boolean(true); // Create a new boolean object.
console.log(typeof b); // object
console.log(typeof true); // boolean
console.log(typeof 'jsman'); // string
console.log(typeof undefined); // undefined
console.log(typeof null); // object
console.log(typeof 1234); // number
console.log(typeof NaN); // number
console.log(typeof Infinity); // number
External references