JS-009
typeof explained in a JavaScript learning illustration — What's inside
Beginner3 min~3 min read#typeof#types#number

typeof

What's inside?

Goal

Learn how to check the type of any value in JavaScript.

Explanation

  • typeof is an operator that tells you the type of a value.
  • It helps you understand whether a value is a number, text, boolean, or another type.
  • This is very useful when debugging programs and checking data.
  • typeof always returns a result as a string.
  • It is one of the simplest tools for exploring values in JavaScript.

Analogy

typeof is like a magnifying glass or scanner that looks inside a box and reports what is inside.

Code

console.log(typeof 42);
console.log(typeof "Hello");
console.log(typeof true);

Result: number string boolean

Common mistake

Beginners often think typeof returns the type itself. In fact, it returns the type name as text, such as "number" or "string".

Remember

  • typeof determines the type of a value.
  • The result of typeof is always a string.
  • typeof helps you inspect data.

Quick Quiz

What will typeof 42 return?

Resources