Changes between Version 1 and Version 2 of Ticket #6581, comment 13


Ignore:
Timestamp:
04/14/2018 05:19:40 PM (20 months ago)
Author:
mjethani
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #6581, comment 13

    v1 v2  
    11I think this blog post says it very well: https://madhatted.com/2016/1/25/let-it-be 
    22 
    3 We should update that line in the style guide: "Use `const` only for constants, not for variables". It's quite simple. In `for (let item of array) {}`, `item` is still a variable, just because it is not reassigned doesn't make it a constant. In `let MAX_VALUE = 2 ** 8 - 1;`, `MAX_VALUE` is a constant, assigning any other value to it would break things; in this case, the `let` keyword may be replaced with `const` to make it clear. 
     3We should update that line in the style guide: "Use `const` only for constants, not for variables". It's quite simple. In `for (let item of array) {}`, `item` is still a variable, just because it is not reassigned doesn't make it a constant. In `let PI = 3.14;`, `PI` is a constant, assigning any other value to it would break things; in this case, the `let` keyword may be replaced with `const` to make it clear.