The typeof Operator
typeof returns the type of a value as a string: number, string, boolean, undefined, object, function, symbol or bigint. Note that typeof null is "object", a famous quirk.
Example
console.log(typeof 42, typeof "hi", typeof true);
console.log(typeof undefined, typeof null, typeof [], typeof (() => 1));Exercise
Check a type.
xQuiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.