Predict typeof Results
Predict Output Easy
Question
What does this code print?
Code
console.log(typeof 42);
console.log(typeof "hello");
console.log(typeof true);
console.log(typeof undefined);
Hint
typeof returns the type name as a string.
Explanation
typeof 42 is 'number', typeof "hello" is 'string', typeof true is 'boolean', and typeof undefined is 'undefined'. Each result is printed on its own line.
Related Resources
Related Lessons
- JavaScript Data Types
Learn about typeof and data types.
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.