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

  1. Create one variable of each core type.
  2. Log each with typeof.
  3. 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.