JS-010
JavaScript diagram about Dynamic Typing: a visual example of One box. Different values
Beginner2 min~2 min read#dynamic-typing#types#variables

Dynamic Typing

One box. Different values.

Goal

Learn that a JavaScript variable can store values of different types.

Explanation

  • JavaScript has dynamic typing.
  • This means the same variable can store values of different types.
  • At first a variable may hold text, then a number, then a boolean.
  • The type belongs to the value itself, not to the variable.
  • That is why JavaScript is called a dynamically typed language.

Analogy

Imagine a regular box. Today it holds a book, tomorrow a ball, and the day after a phone. The box stays the same — only its contents change.

Code

let data = "Hello";

data = 42;

data = true;

Result: data → true

Common mistake

Beginners often think a variable must always store one data type. In JavaScript, that is not the case.

Remember

  • JavaScript has dynamic typing.
  • One variable can hold different data types.
  • The type belongs to the value, not the variable.

Quick Quiz

What does dynamic typing mean?

Resources