Variables, Data Types, Operators, and Type Conversion
Build the core JavaScript foundation with variables, primitive types, operators, and a clear understanding of dynamic typing.
Inside this chapter
- let, const, and var
- Primitive Data Types
- Operators
- Dynamic Typing and Conversion
- Equality Nuance
- Real Example
Series navigation
Study the chapters in order for the clearest path from JavaScript basics and browser setup to asynchronous programming, APIs, performance, and advanced engineering practices. Use the navigation at the bottom to move smoothly through the full tutorial series.
let, const, and var
let count = 0;
const appName = "LearnJS";
var oldStyle = "legacy";
Modern JavaScript strongly favors let and const. Beginners should understand var mostly so they can read older code and recognize why block scope with let and const is usually better.
Primitive Data Types
- string
- number
- boolean
- null
- undefined
- symbol
- bigint
Operators
let total = 10 + 5;
let isLarge = total > 10;
let isReady = true && isLarge;
Arithmetic, comparison, logical, assignment, and conditional operators appear constantly in everyday JavaScript.
Dynamic Typing and Conversion
console.log("5" + 2); // "52"
console.log(Number("5") + 2); // 7
JavaScript’s type conversion rules are powerful but can surprise beginners. Strong engineers learn to be explicit when clarity matters.
Equality Nuance
Students should prefer strict equality === over loose equality == in most cases. Strict equality avoids implicit coercion surprises.
Real Example
An invoice calculator in a web application may combine entered numeric strings, discount logic, and tax conditions. Clear variable use and explicit conversion are what prevent subtle bugs there.