JavaScript Variable

Variables are used to store values or expressions.

Declare Variables in JavaScript

Before using a variable, we first need to declare it. We declare a JavaScript variable with the var keyword:

Example: var name;

After the declaration, the variable has no value. We can assign a value to the variable either while declaring the variable or after declaring the variable.

Example: var name = “DoubleD”;

OR

var name;

name = “DoubleD” ;

Leave a comment

Design a site like this with WordPress.com
Get started