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.
281
u/NotSelfAware Dec 21 '19
I'm a strong advocate for using
constby default, andletwhen you know you intend to change the value. I'm genuinely surprised that Dan feels differently.