Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JS Variables

JavaScript variables serve as containers for storing data and can be declared in four ways:

  • Automatically
  • Using var
  • Using let
  • Using const

In this initial example, x, y, and z are considered undeclared variables.

They are automatically declared upon their first usage.

Example

x = 5;
y = 6;
z = x + y;
Note: It is widely regarded as good programming practice to declare variables before they are used.

From the examples provided, it can be inferred that:

  • x holds the value 5
  • y holds the value 6
  • z holds the value 11