JavaScript Theory
Variables in javascript:
A variable is a name which is associated with a value that can be changed. It is a name of memory location.
Types of variable:
Local variables:
The variable are declared inside a function is called local variable. That means it cannot access the outside that function.
Syntax |
---|
function skill() { var x = 10; // Local variable } |
Global variable:
The variables are declared outside the function is called global variable.
Syntax |
---|
var x = 10; // Global variable function skill() { document.writedocument.write(x); } skill(); // calling function |
Data Types in java script:Data types specifies the type of values that can be stored in the variable. There are two types of data types in java script.
Primitive data types
|
StringThis data type is used to represents sequence of characters. Ex. "SkillPundit".NumberThis data type is used to represents numeric values. Ex. 25, 65.39, 54.BooleanThis data type is used to represents boolean values Ex. Ture or false.NullThis data type has only one value i.e. null. It has no value. Non-primitive data types
|