Variable Definition -: A variable is a container for information we want to store. A variable’s value can change during the script. You can refer to a variable by name to see its value or to change its value.
Rules for variable name -:
- variable names are case sensitive means uppercase and lower case are different to each other.
- They must begin with a letter or the underscore character
Important-: java script is case-sensitive! means if we give the variable name as like strname it is not same STRNAME .
Declare a variable -: we can create a variable with the var statement : var strname=some value we can also create a variable without the var statement -: strname=some value.
Value assign a variable name-: we can assign a value in java script as like ……. var strname=”netnic”
The variable name is on the left side of the expression and the value we want to assign to the variable is on the right. Now the variable “strname” has the value is netnic.
<title>tips and technic of computer and internet</title>
var name =”netnic”
Scope of variables-: when we declare a variable function the variable can only be accessed within that function. when we exit the function the variable is destroyed. These variable called local variable. we can use local same variable in different function because each variable is recognized by the function and after closing the function variable are destroyed.
Important-: in the java script variable function are not important. The may be interchanges necessary. This means that if a variable is a string one minute,it can be as integer the next time .