title: global object not working in Visual Studio Code [ JavaScript ]
body: <p>I have the following code:</p>
  
  <pre><code>var myFriend = 'David';
  function Hi(){
     var myFriend = 'Emma';
     console.log(global.myFriend); //prints undefined
  }
  Hi();
  </code></pre>
  
  <p>I am trying to access the global variable myFriend inside the function. I am unable to understand why it is printing undefined. Can someone please explain?</p>