JS-003
Educational JavaScript lesson graphic for Primitive Types: Learn the basic data types in JavaScript
Beginner3 min~3 min read#types#primitives#string

Primitive Types

The basic building blocks

Goal

Learn the basic data types in JavaScript.

Explanation

  • Every piece of information in JavaScript has a type.
  • Numbers are used for mathematical calculations.
  • Strings store text.
  • Boolean has only two values: true or false.
  • null means an intentionally empty value.
  • undefined means the value has not been set yet.

Analogy

Data types are like different kinds of LEGO bricks. They look different, but your whole program is built from them.

Code

let age = 42;

let name = "Vitalii";

let isAdmin = true;

let empty = null;

let future;

Result: 42 "Vitalii" true null undefined

Common mistake

Beginners often confuse null and undefined. They are different values with different purposes.

Remember

  • Number — numbers.
  • String — text.
  • Boolean — true / false.
  • null — intentionally empty.
  • undefined — no value yet.

Quick Quiz

Which type is used for text?

Resources