- logical comparison
- operator precedence
- Js break continue
- with void statement
- reserved keywords
- HTML DOM Nodes
- document object
- write document
- DOM node properties
- jscript create nodes
- jScript dom attribute
- window open/close
- Window Object
- window print method
you use variables to store, retrieve,and manipulate values that appear in you code.
declaring a variable is the process of telling the interpreter to get the ready to store data in a new variable.in javascrip variables are declared using the var keyword with the name of the variable you wish to declare.
the rules for creating legal variable names are as follows:
- the first character of a variables name cannot be a digit.
- the variable name must not be a reserved word.
- A variable name cannot start with a number (0-9)
- subsequent characters must be letters, numbers, dolar $, or underscores(_).
a variable stores data.every variable has a name, called its identifier.
note:a variable declared using the var statement with no initial value specified has the value undefiend.
to assign a value to the variable, use the equal sign:
age = 34
bool = true
note :- you can declare many variables in one statement.start the statement with var and separate the variables by comma:
implicit variable declaration
note : you should not use this variant.
widgates = 10 ;
var widgates = 10 ;
you can declare constant variables with the const keyword.
you cannot declare a constant with the same name as a function or variable in the same scope.
the scope of a variable is all parts of a program where it is visible.visible means that the variable has been declared and is available for use.
a variable that is visible everywhere in the program has global scope.a variable that is visible only in a specific context like a function has local scope.
all of variables that declared inside the function have local scope.
the high-level languages including c, c++, java are strongly typed.that is, a variable must be declared before it is used, and its type must be included in its declaration.once a variable declared, its type cannot be change.
weakly typed language variable and literal has a type, but data types are not explicitly declared.for example, we might define a variable datavalue to hold number and set it to a value of 4444.
var datavalue ; // undefined datatype datavalue = 4444; // now number datatype datavalue = "java" // now string datatype