typeof Operator, online

Six activities your students do on their own devices. See who's finished, and their scores.

typeof Operator in one minute

What students need to know

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.

Mistakes students make

  • The operator is 'typeof', not just 'type'.
  • 'typeof' must be lowercase - a capital T causes an error.
  • This line is actually correct - typeof can be used with or without parentheses.
  • Missing space between 'typeof' and the variable name.

Discover other journeys with this module

What students will learn in this module

Every question in Module 9

Quick questions

  1. Does typeof return a string naming a value's data type?AYesBNo
  2. Is 'type' by itself a valid JavaScript operator?AYesBNo
  3. Must 'typeof' be written in lowercase?AYesBNo
  4. Can typeof be used on a variable or a direct value like 42?AYesBNo
  5. Does typeof true return "boolean"?ANoBYes

Key terms

Students type the meaning of:

  • typeof

Match the pairs

typeof "hello"Match it to what it does
typeof 42Match it to what it does
Checks the data type of a valueMatch it to what it does
Returns a string naming a boolean's typeMatch it to what it does
console.log(Typeof name);Match it to what it does
console.log(type age);Match it to what it does

Fill in the blanks

  1. console.log(______ name);

    Hint: Type the operator that returns a value's data type.

  2. console.log(______ age);

    Hint: Type the operator that returns a value's data type.

  3. let result = ______ isReady;

    Hint: Type the operator that returns a value's data type.

  4. console.log(______ 42);

    Hint: Type the operator that returns a value's data type.

  5. let kind = ______ "hi";

    Hint: Type the operator that returns a value's data type.

Spot the error

Question 1

Alet x = 5;Bconsole.log(type x);Clet y = true;

Question 2

Aconsole.log(Typeof name);Blet name = "Amy";Clet age = 10;

Question 3

Alet flag = true;Bconsole.log(typeof(flag));Cconsole.log(typeof flag);

Question 4

Aconsole.log(typeofn);Blet n = 5;Cconsole.log(typeof n);

Question 5

Alet s = "hi";Bconsole.log(typeof s);Cconsole.log(typof s);