LESSON 5
Data Types
Learning objective: Recognize JavaScript's core data types.
Understand
Values in JavaScript come in different types.
The core types are string (text), number, boolean (true/false), null, undefined, plus objects and arrays. Use typeof to check a value's type.
Analogy: Data types are like categories of ingredients: liquids, solids, and spices each behave differently.
See It in Action
Checking types:
typeof "hi"; // 'string'
typeof 42; // 'number'
typeof true; // 'boolean'How it works:
typeof reports the type of each value, helping you understand and debug what you are working with.Try It Yourself
- Create one variable of each core type.
- Log each with
typeof. - Note which types surprise you.
Quick Quiz
Which is NOT a JavaScript data type?
Challenge
Create variables covering string, number, and boolean and log their types.
Success condition: Your console shows the correct type for each variable.
+10 XP
Lesson Complete
You answered correctly and completed the required practice. Your progress has been saved on this device.
Continue to next lesson →