Google News
logo
JavaScript - Interview Questions
What is Javascript Variables ?
JavaScript uses reserved keyword var to declare a variable. A variable must have a unique name. You can assign a value to a variable using equal to (=) operator when you declare it or before using it.

There are two types of variables in JavaScript  :
 
1. local variables  : A variable that is declared inside of a function definition is called local variable and has scope to that function only. 
2.global variables :  A variable that is declared outside of a function definition is called a global variable and its scope is throughout your program means its value is accessible and modifiable throughout your program.

Basic Syntax :
var <variable-name>;
var <variable-name> = <value>;
Advertisement