(ES6) ES6 (2016)

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:



Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23>  <24>  <25
Link to this page: http://www.vb-net.com/JavascriptES6/GL03.htm
<TAGS>  <ARTICLES>  <FRONT>  <CORE>  <MVC>  <ASP>  <NET>  <DATA>  <TASK>  <XML>  <KIOSK>  <NOTES>  <SQL>  <LINUX>  <MONO>  <FREEWARE>  <DOCS> <TRAVELS> <FLOWERS> <RESUME> < THANKS ME>