title: Is var the only option we have for declaring global variables and functions?
body: <p>On this page:</p>
  <p>I found that it is important to use var and we can not use let and const for declaring global variables and functions but I tried to do use let and const. So should I use them or they are not recommended?</p>
  <p>Here is my code that I ran:</p>
  <pre><code>let a;
  globalThis.a = 3;
  console.log(globalThis);
  </code></pre>
  <p>and here is the output:</p>
  <p><a href="https://i.stack.imgur.com/NXEpt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NXEpt.png" alt="enter image description here" /></a></p>
  <p>So you can clearly see a gets added without any error. So should I continue using this or this works but not recommended?</p>