typeof Operator
The typeof operator can be used to determine the type of a variable. It returns a string representing the datatype of the value.
The typeof operator has two forms, an operator or a function.
// function
typeof(10); // returns "number"
// operator
typeof 10; // return "number"
typeof("hello"); // return "string"
typeof(true); // return "boolean"
typeof(undefined); // returns "undefined"
typeof(null); // returns "object" it's a bug!!
Last updated
Was this helpful?