JavaScript variables are containers for storing data values.

In this example, xy, and z, are variables:


Example

var x = 5;

var y = 6;

var z = x + y;

From the example above, you can expect:

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

Much Like Algebra

In this example, price1price2, and total, are variables:


Example

var price1 = 5;

var price2 = 6;

var total = price1 + price2;


In programming, just like in algebra, we use variables (like price1) to hold values.

In programming, just like in algebra, we use variables in expressions (total = price1 + price2).

From the example above, you can calculate the total to be 11.

Jay Kakadiya

Jay Kakadiya Creator

I am a computer field, & i am Web developer.

Suggested Creators

Jay Kakadiya