Fundamentals

Variable in JavaScript

What is a Variable?

A variable is a named container used to store data values that can be used and modified throughout a program.

Declaring Variables

var name = "John";
let age = 25;
const PI = 3.14;

Naming Rules

  • Must begin with a letter, underscore _, or dollar sign $.
  • Cannot start with a digit or contain spaces.
  • Case-sensitive — age and Age are different variables.
  • Cannot use reserved keywords as variable names.

Ready to master real-world JavaScript development?

Learn JavaScript hands-on with mentor-led, live sessions.

Explore Course