All programming languages has one common characteristics is variables. Variables are useful to hold the data value, which is constantly changing.
var a = 10; var b = 10; var addition, subtraction, multiplication, division; addition = a + b; //20 subtraction = a - b; //0 multiplication = a * b; //100 division = a / b; //1
a = 10; b = 10; addition = a + b; //20 subtraction = a - b; //0 multiplication = a * b; //100 division = a / b; //1
Note: We strongly recommended you to use the var keyword to declare the variables before to use it. If you use the var keyword to declare the variables so the variables will be declared in the any function scope and it will be destroyed automatically when the execution of the function is over.
But when you use the variables without the declaring than it will be available to the global scope and also we can say the variables are indirectly declaring in the page scope and it is automatically become the part the of the page scope so it will be never destroyed from the memory till the page is displaying the browser, and it become the leads to the memory leakage.
Variables which is used without the declaring, it will automatically becomes the property of the window object, so that variables are accessible from anywhere in the page. So we request you to never use the variables without declaring it.
Loosely typed variables:
Loosely typed variables means the variables first declare as the string and holding the string, and after that it can also hold any type of the value like number, boolean or object also.
var name = 1; name = "jhon"; name = 99.9; name = false; name = null;