JavaScript Variable

JavaScript variables are containers for storing data values. Variables are containers for values of all possible types like number, string , array. Every variable gets a name that can later be used inside your application to read/write its value.

Examples 
var A = 100; 
var name = "Nitin Kumar";
var variable1 = 200;

or

var x;
x=100;


Steps to create variable in java script:-
  1. Declaration
  2. Initialization
  3. Assignment


Declaration
Initialization
Assignment
The variable is registered using a given name within the corresponding scope
When you declare a variable it is automatically initialized, which means memory is allocated for the variable .

Here a specific value is assigned to the declared variable.

Warning : - Variable Name must start with a letter (a to z or A to Z), underscore( _ ), or dollar( $ ) sign , After first letter we can use digits (0 to 9),and remember all javascript variables are case sensitive.

JavaScript Variable Scope

JavaScript variables can have only two scopes.
Global Variables
Local Variables
A global variable has global scope which means it can be defined anywhere in your code.
A local variable will be visible only within a function where it is defined.


Warning : - JavaScript Reserved Words cannot be used as JavaScript variables, functions, methods, loop labels, or any object names.

Reserved Words:-
details of reserved words are given bellow.
continue
boolean
break
byte
case
catch
char
class
if
implements
import
do
throws
transient

Double
new
null
package
private
protected
public
return
const
finally
debugger
else
enum
export
default
delete
float
for
function
goto
typeof
var
void
volatile
while
with
true
try

extends
false
final
abstract
instanceof
int
interface
short
static
super
switch
synchronized
this
throw
long
native