Check Type with typeof
Fill in the Blank Beginner
Question
Fill in the blank to check if `value` is of type number.
Code
const value = 42;
if (___ value === "number") {
console.log("It's a number!");
}
Hint
Use the operator that returns the type as a string.
Explanation
typeof is the operator that returns the type of a value as a string. typeof 42 returns "number", so the comparison typeof value === "number" is true and the message is printed.
Related Resources
Related Lessons
- JavaScript Data Types
Learn about typeof.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.