JS-001
Variables explained in a JavaScript learning illustration — Boxes for your data
Beginner2 min~2 min read#variables#memory#basics

Variables

Boxes for your data

Goal

Learn what a variable is and why programmers use it.

Explanation

  • Imagine a regular box. You can put anything inside it and take it out later.
  • In JavaScript, a variable plays the role of that box.
  • A variable has a name. Through that name, the program knows where the stored value lives.
  • Once you write a value, you can use it as many times as you need.
  • This lets programs remember information between different instructions.

Analogy

A variable is like a labeled box. The label on the outside says 'name', and 'Vitalii' is stored inside.

Code

let name = "Vitalii";

console.log(name);

Result: Vitalii

Common mistake

Beginners often think a variable is the value itself. In reality, it is a place where the value is stored.

Remember

  • A variable stores data.
  • Every variable has a name.
  • You can get the value through its name.

Quick Quiz

What does a variable store?

Resources