Variables and Primitive Types
AvailableLesson 1 of 25 · Syntax · Easy
The big idea
A variable is a named spot where JavaScript remembers a value for you. In JavaScript, write let (or const if the value will not change), then the name, an equals sign =, and the value: JavaScript detects whether a value is a number, text, or true/false automatically.
Think of it like this: Think of a variable like a labeled jar on a shelf: `let x = 5;` puts a label called `x` on the jar and drops `5` inside.
Read the lesson
A variable is a named spot where JavaScript remembers a value for you.
In JavaScript, write let (or const if the value will not change), then the name, an equals sign =, and the value:
let age = 20; // a number
const price = 9.99; // a decimal number
let name = "Maya"; // text (a string)
let isReady = true; // true or false (a boolean)
JavaScript detects whether a value is a number, text, or true/false automatically. You do not need to write a type name.
Quick check
Which keyword creates a variable in modern JavaScript?
Your challenge
Create a variable named x and set it to 5 (type let x = 5;).
More learning tools(compare languages, visual guide, related lessons)
Compare with another language
Similar to python.variables-types (85% overlap). Variables & primitive types: compare let/const (JS), auto/int (C++), := (Go), let mut (Rust), and column types (SQL).
Visual walkthrough
A diagram, a step-by-step animation, and short captions for Variables and Primitive Types.
Learn this first
Nothing needed - you can start here.