The FundamentalsTuesday, January 27, 2026

Variables & Data Types

How computers remember things.

Advertisement

Support JS Mastery Path by checking out our sponsors.

Data is the lifeblood of any application. Variables are how we capture, store, and label that data so we can use it later.

The Warehouse Mental Model

Imagine your computer's memory (RAM) is a massive Amazon Warehouse.

1. The Variable: This is a specific box on a specific shelf.
2. The Variable Name: This is the sticker label you put on the box (e.g., "userEmail").
3. The Value: This is what you put inside the box (e.g., "john@example.com").

Without the label (variable name), you would throw data into the warehouse and never find it again.

The Three Keywords

In modern JavaScript (ES6+), we have specific rules for creating variables.

const (The Standard)

Short for "Constant". Once you put data in this box, you cannot replace it. This is the safest option because it prevents you from accidentally overwriting important data.

const taxRate = 0.2;

let (The Variant)

Use this ONLY when you know the value needs to change later (like a score in a game, or a counter loop).

let score = 0;
score = 10;
Note: There is an older keyword called var. Do not use it. It has weird scoping rules that cause bugs. If you see it in old tutorials, replace it with let or const.

Assignment vs. Equality

This is the #1 confusion for beginners. In math, = means "is equal to". In programming, it means "set to".

assignment.js
let score = 100; // "Set score to 100"

score = 200; // "Set score to 200"

// We read this right-to-left:
// 1. Calculate score + 50 (250)
// 2. Put that result back into 'score'
score = score + 50; 

console.log(score);
Advertisement

Support JS Mastery Path by checking out our sponsors.

Safety Check: Reassigning Const

What happens if we break the rules? Professional developers love errors because they tell us exactly what went wrong. Try running this code and look at the error message in the console.

error-test.js
const appName = "JS Mastery";

// TRY TO RUN THIS
// You will see: "TypeError: Assignment to constant variable."
appName = "Something Else"; 

console.log(appName);

Naming Like a Pro

Code is read by humans more often than by computers. We use a convention called camelCase.

TypeExampleWhy?
GooduserEmailAddressDescriptive. Starts lowercase. Capitalizes new words.
BadUserEmailAddressCapitalized start usually means a "Class" or "Component".
Terribleu, x, dataWhat is u? What is data? Be specific!
Advertisement

Support JS Mastery Path by checking out our sponsors.