← JavaScript

typeof Operator

An operator that returns a string naming the data type of a value.

Understanding typeof Operator in JavaScript

What it does: typeof is exactly the operator used to check a value's type. typeof true returns the string "boolean". JavaScript is case-sensitive, so 'typeof' must be lowercase. typeof works on both variables and literal values. typeof correctly identifies true and false as booleans. 'typeof' is a single word with no space in the middle. Both typeof x and typeof(x) are valid syntax. Text wrapped in quotes has the type "string".

Common mistakes: The operator is 'typeof', not just 'type'. 'typeof' must be lowercase - a capital T causes an error.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 1–10) and word search (Modules 1–29).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Does typeof return a string naming a value's data type?
YesNo
Matches
console.log(Typeof name);
↓
Wrong - 'typeof' must be lowercase
Applying
Meanings
Term
typeof
Meaning
An operator that returns a string naming the data type of a value.
Practice
let name = "Sam";
Testing
Gaps
console.log( name);
Check Answer
Spots
1let x = 5;
2console.log(type x);

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Walrus' badge — Method Master, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Does typeof return a string naming a value's data type?
A. Yes ✓
B. No
typeof always returns a string like "number" or "string".
2. Is 'type' by itself a valid JavaScript operator?
A. Yes
B. No ✓
The full operator is 'typeof', not just 'type'.
3. Must 'typeof' be written in lowercase?
A. Yes ✓
B. No
JavaScript is case-sensitive, so 'typeof' must be lowercase.
4. Can typeof be used on a variable or a direct value like 42?
A. Yes ✓
B. No
typeof works on both variables and literal values.
5. Does typeof true return "boolean"?
A. No
B. Yes ✓
typeof correctly identifies true and false as booleans.

Match the Pairs

typeof "hello" → Returns "string"
typeof 42 → Returns "number"
Checks the data type of a value → typeof
Returns a string naming a boolean's type → typeof true
console.log(Typeof name); → Wrong - 'typeof' must be lowercase
console.log(type age); → Wrong - the full operator is 'typeof', not 'type'

Key Term

typeof
An operator that returns a string naming the data type of a value.

Fill in the Blanks

1. console.log(typeof name);
Hint: Type the operator that returns a value's data type.
2. console.log(typeof age);
Hint: Type the operator that returns a value's data type.
3. let result = typeof isReady;
Hint: Type the operator that returns a value's data type.
4. console.log(typeof 42);
Hint: Type the operator that returns a value's data type.
5. let kind = typeof "hi";
Hint: Type the operator that returns a value's data type.

Spot the Error

Question 1
A let x = 5;
B console.log(type x);
C let y = true;
Line B — The operator is 'typeof', not just 'type'.
Question 2
A console.log(Typeof name);
B let name = "Amy";
C let age = 10;
Line A — 'typeof' must be lowercase - a capital T causes an error.
Question 3
A let flag = true;
B console.log(typeof(flag));
C console.log(typeof flag);
Line B — This line is actually correct - typeof can be used with or without parentheses.
Question 4
A console.log(typeofn);
B let n = 5;
C console.log(typeof n);
Line A — Missing space between 'typeof' and the variable name.
Question 5
A let s = "hi";
B console.log(typeof s);
C console.log(typof s);
Line C — 'typeof' is misspelled as 'typof'.

Student with a class code? Join your class →