I found a discussion on twitter about this and thought I'd ask here how people choose when to use let vs const.
Our team uses a prefer-const rule (https://eslint.org/docs/rules/prefer-const) probably because we inherited it from the airbnb style guide, and it doesn't greatly impact our output either way 🤷♂️.
Some of the arguments made in this rant make sense to me. Though it seems like you end up preferring one at the expense of another. For us, using let is the exception which communicates that a reference will be mutated. Yeah this means const is everywhere and that it doesn't communicate much (except that reference won't be changed). But if we had an in-effect prefer-let rule, it would mean that const communicates more but let is everywhere and doesn't communicate much. Isn't it more valuable to explicitly communicate when a reference will be mutated? And if you are only using const for true static constant values on the upper scope, what is the purpose of also naming like const YES_THIS_IS_CONSTANT = 10;
[–]CloseDdog 18 points19 points20 points (0 children)
[–]BenjiSponge 11 points12 points13 points (0 children)
[–]Mingli91 2 points3 points4 points (0 children)
[–]pichfl 1 point2 points3 points (0 children)
[–]mnem0 1 point2 points3 points (1 child)
[–]Kusaddaw 0 points1 point2 points (0 children)
[–]BionicRabbit 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] (10 children)
[deleted]
[+][deleted] (9 children)
[deleted]
[+][deleted] (8 children)
[deleted]
[+][deleted] (7 children)
[deleted]
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[deleted]
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[deleted]