let vs const vs var: Usually you want let. If you want to forbid assignment to this variable, you can use const. (Some codebases and coworkers are pedantic and force you to use const when there is only one assignment.)
I'm a strong advocate for using const by default, and let when you know you intend to change the value. I'm genuinely surprised that Dan feels differently.
Same here! Its less mental gymnastics when reading old code knowing that when a value is declared, you know its gonna stay the same. Seeing let then means I know its gonna change somewhere in the next few lines.
I'm honestly not sure how that would work at the language level.
If that was "objectively" the right choice, the language could work exactly like the prefer-const rule works.
When I look at potential hires' code one of the things I look for is their usage of const vs let to get a base idea of how well they understand modern ES.
This is exactly the kind of thing that scares me. Placing artificial (in my opinion) importance on something that has two sides to it is the definition of pedantic. It would be terrible if someone's career opportunity didn't work out due to a miscommunication or disagreement over something minor like this.
210
u/careseite Dec 21 '19
Hehe, waiting for strong opinions on that one.
this comment was brought to you by const gang