- Variable is container for storing the information.
- Variable names are case sensitive. (x and X are two different variable).
- Variable names must be started with letter or underscore.
- Syntax: VAR <variable name>
- If you assign values to variables that have not yet been declared, the variables will
automatically be declared.
var x = 10; < - - - - - variable x is declared.
var y = 20; < - - - - - variable y is declared.
z = x+y; < - - - - - variable z is not declared.
document.write('addition is' + z);
accessed within that function. (The variable has local scope).
- You can have local variables with the same name in different functions, because local
variables are only recognized by the function in which they are declared.
- Local variables are destroyed when you exit the function.
- Variables declared outside a function become GLOBAL, and all scripts and functions
on the web page can access it.
- Global variables are destroyed when you close the page.
- If you declare a variable, without using "var", the variable always becomes GLOBAL.
Data Types in Java Script:
1)Number:Integer Number,Float Number,NaN
2)String:it include charachter and words
3)Boolean:return TRUE or FALSE