title: Benefit of const vs let in TypeScript (or Javascript)
body: <p>I was reading the <a href="https://basarat.gitbooks.io/typescript/content/docs/const.html" rel="noreferrer">TypeScript Deep Dive</a> and I see that both <code>let</code> and <code>const</code> are block scoped, which is great. Obviously, a const cannot be changed (it is immutable). But why is ReSharper is encouraging me to change as many <code>let</code>s to <code>const</code> as I can? I'm assuming ReSharper thinks there is a performance gain in using <code>const</code> over <code>let</code>? Is there a speed difference between <code>const</code> and <code>let</code>? Is there a different reason to use <code>const</code>? Take the following example:</p>
  
  <pre><code>for (let i = 0; i &lt; this.InputControl.ParentQuestions.length; i++) {
      const id = this.InputControl.ParentQuestions[i].ParentId;
      const value = this.InputControl.ParentQuestions[i].ParentRequiredAnswer;
      if (!formVals[id]) return false;
      if (formVals[id].toLowerCase() != value.toLowerCase()) return false;
  }
  </code></pre>
  
  <p>Previously, I had <code>let id</code> and <code>let value</code> but ReSharper asked me to change them to <code>const</code>, which works, but why is it better in this case? Or in any case?</p>
  
  <p>I also found <a href="https://stackoverflow.com/questions/38858743/in-typescript-when-do-you-use-let-and-when-do-you-use-const">this question on SO</a>, but it talks more about what <code>let</code> and <code>const</code> do, not so much why one is better than the other. It does say to use <code>const</code> as much as possible, but what benefit does that provide?</p>