Next →

What Are Variables?

Variables are containers for storing data values. They allow you to label and reference data in your program. In JavaScript, variables can be declared using var, let, or const.

Example:

let name = "Alice";

Declaring Variables

Example:

let age = 25;
const pi = 3.14159;

Data Types in JavaScript

JavaScript has several data types, divided into primitive types and objects.

Primitive Types

Objects

Objects store collections of key-value pairs, arrays, and functions.

Example:

let user = { name: "Alice", age: 25 };

Changing Variable Values

Variables declared with let or var can be reassigned:
let score = 10;
score = 15;

Variables declared with const cannot be reassigned.