title: Let or Var in modern javascript?
body: <p>"<code>Let</code> allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used. This is unlike the <code>var</code> keyword, which defines a variable globally, or locally to an entire function regardless of block scope." - <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let</a></p>
  
  <p>Which one should be used in modern javascript code? <code>let</code> or <code>var</code>?</p>
  
  <p>Edit: 
  I checked the Google JavaScript Style Guide and it states "Declarations with var: Always" (<a href="https://google.github.io/styleguide/javascriptguide.xml" rel="nofollow noreferrer">https://google.github.io/styleguide/javascriptguide.xml</a>)</p>
  
  <p>But in the tutorial at javascript.info (not sure if this is an official JavaScript website or not) it says to use <code>let</code> (<a href="https://javascript.info/variables" rel="nofollow noreferrer">https://javascript.info/variables</a>)</p>
  
  <p>I'm assuming I should stick to what Google recommends, but am still open to answers.</p>
  
  <p>Second Edit: The above is not the most recent Google JavaScript Style Guide. In that one it states: "Declare all local variables with either <code>const</code> or <code>let</code>. Use <code>const</code> by default, unless a variable needs to be reassigned. The <code>var</code> keyword must not be used".(<a href="https://google.github.io/styleguide/jsguide.html#features-local-variable-declarations" rel="nofollow noreferrer">https://google.github.io/styleguide/jsguide.html#features-local-variable-declarations</a>)</p>