6 ms·
Const whenever possible.
by grajaganDev 2y ago
Const whenever possible.
- NotAnOtter 2y agoFunny, that's not my preferred one nor the teams
- grajaganDev 2y agoShould it be mutable or not? Seems reasonable to answer up front by choosing const or let. What are other considerations?
- NotAnOtter 2y agoAfter thinking about it a bit more, I think I am actually on your side. I previously claimed to be on "Const when things should never locally change". But thinking through the example function expectedRevenuePerAttempt() { (const/let) successRate = success / attempt; return successRate * revenuePerSuccess } I would prefer to use const there.
- taylodl 2y agoI'm with you, const whenever possible. Fewer things to reason about and chase down while diagnosing issues or debugging. I also thought this was the default for a majority of developers.
- grajaganDev 2y agoRight, the hope is to find bugs early.
- SkySkimmer 2y agoThis is what I would call const correctness, because it is correct.