91-9990449935 0120-4256464 |
JavaScript VariableA JavaScript variable is simply a name of storage location. There are two types of variables in JavaScript : local variable and global variable.
There are some rules while declaring a JavaScript variable (also known as identifiers).
Correct JavaScript variablesIncorrect JavaScript variablesExample of JavaScript variableLet’s see a simple example of JavaScript variable. Test it NowOutput of the above exampleJavaScript local variableA JavaScript local variable is declared inside block or function. It is accessible within the function or block only. For example: Or, JavaScript global variableA JavaScript global variable is accessible from any function. A variable i.e. declared outside the function or declared with window object is known as global variable. For example: Test it NowTo know more about global variable (e.g. how global variable is executed by JavaScript execution engine), visit next page.
Next TopicJavaScript Global Variable
|