Globalscope (GL03)
1: // In a Node.js environment.
2: global.globalVar = "I'm global (Node.js)!"; // Explicitly add to global scope with `global.`
3: var globalVarWithVar = "Also global, but with var";
4: let globalLet = "Global let (NodeJS)"
5:
6: console.log(global.globalVar); // Output: I'm global (Node.js)! (accessing via `global`)
7: console.log(globalVarWithVar); // Output: Also global, but with var (directly)
8: console.log(globalLet); // Output: Global let (NodeJS)
9:
10: function myFunction() {
11: console.log(globalVarWithVar); // Also global, but with var
12: }
Global Scope (Node.js): In Node.js, the global scope is represented by the global object. I'm global (Node.js)! Also global, but with var Global let (NodeJS)
Globalscope context:
ES6 context:
- (2024) Notes about JS Closures. #ES6
- (2024) Notes about Javascript asynchronous programming. #ES6
- (2022) Modern Javascript books #ES6 #Doc
- (2021) JS learning start point #ES6
- (2021) Maximilian Schwarzmüller Javascript lecture #ES6
- (2021) Javascript interview question from Happy Rawat #ES6
- (2021) Javascript tests #ES6
- (2016) New unique features of Javascript (updated). #ES6
Comments (
)

Link to this page:
http://www.vb-net.com/JavascriptES6/GL03.htm
|