elibraryportal Logo

JS Variable

Variable means which hold the data value and it can be changed anytime.

Javascript use the var keyword declare a variable.where a variable must have a unique name.

Example:-

Test it Now

Types of variable.

There are two types of variable that is.

  1. Local variable
  2. Global variable.

1) Local variable in Javascript with Example

A local variable declared inside the function or block.

Example:-

Test it Now

2) Global variable in Javascript with Example

A global variable is declared outside the function that is called Global variable.

Example:-

Test it Now
Next TopicJS DataType