The typeof
operator returns a string indicating the type of the operand.
typeof operand;
console.log(typeof 1000); // Prints: number
console.log(typeof '1000'); // Prints: string
console.log(typeof false); // Prints: boolean
console.log(typeof 142n); // Prints: bigint
function hello(){}
console.log(typeof hello); // Prints: function
class User {}
console.log(typeof User); // Prints: function
console.log(typeof {message: "Hello World"}); // Prints: object
The typeof
operator returns the value of the given operand, where the operand can be class, variable, functions, objects, etc.