Replacing let
with const
Even when it feels impossible
3 min readApr 5, 2021
In JavaScript, const
affords a few benefits:
- It lets the team reviewing your code that the value is not going to change, improving confidence.
- It throws an error if you attempt to change that variable, preventing accidental re-assignment.
- It allows the engine to optimize for unchanging values.