JavaScript Global VariableA JavaScript global variable is declared outside the function or declared with window object. It can be accessed from any function. Let’s see the simple example of global variable in JavaScript. Test it NowDeclaring JavaScript global variable within functionTo declare JavaScript global variables inside function, you need to use window object. For example: Now it can be declared inside any function and can be accessed from any function. For example: Test it NowInternals of global variable in JavaScriptWhen you declare a variable outside the function, it is added in the window object internally. You can access it through window object also. For example: Next TopicJavaScript Data Types |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India