JavaScript by Patrik

Definition of var

The var statement declares a variable.

Variables are containers for storing information.

Creating a variable in JavaScript is called "declaring" a variable:

var message;

After the declaration, the variable is empty (it has no value).

To assign a value to the variable, use the equal sign:

message = "Hello";

You can also assign a value to the variable when you declare it:

var message = "Hello";

Comments