Toggle navigation
Genres
Frontend (2)
JavaScript (6)
Database (2)
Linux Server (3)
Web Apps (4)
Misc (4)
Search
List
New Tutorials
Last Modified Tutorials
</>
Code examples
code
smiko
javascript
advanced
variables
16var_global_browser.js
16var_global_browser.js
/** * GLOBAL VARIABLES in BROWSER * There are three ways to define variable in global scope * Each variable in global scope is assigned to 'window' object. * Examples are in global scope */ //first - global scope var a = 15; console.log(this.a); console.log(window.a); //second - global scope b1 = 'some text'; console.log(this.b1); console.log(window.b1); //second - local scope function fja1() { b2 = 212; } fja1(); console.log(b2); //third - global scope window.c1 = 34; console.log(c1); //third - local scope function fja2() { window.c2 = 342; } fja2(); console.log(c2);
Reload page
Preview
W3C validation
Edit Code
JS Console