Are there any performance gains from using `const` instead of `let`?
If not then I don't understand why people do it.
Are there any performance gains from using `const` instead of `let`?
If not then I don't understand why people do it.
I don't think so 🤔 I think it's more to show an intend to the reader. I always use const unless I really need a let. But honestly that happens maybe twice a year, being a full time web dev 😃
And there's still var 😁
Well and then reassigning const throws an error, so at least you'll know when you try to change a variable you probably shouldn't change
const clearly states intent, it's good for longevity of the code especially with multiple maintainers. Not sure about performance, I can imagine a runtime can make some assumptions for performance if it knows it's a const.
I have absolutely no idea what you're asking. What I do know is that you're a "Zen Master" at this kind of shit🤷🏻♂️. Just meditate a bit, the answer will come🙏🏻.
Security is probably a bigger concern. Sometimes you want to make sure a value does not change after assignment. Like when you have a process dealing with personal / sensitive data, account numbers, #sats, etc.. :)
If you're concerned with security should you really be writing JavaScript? `const` doesn't really mean a constant value.
Zig had ‘let’ and ‘let mut’ at one point, then removed them in favor of just ‘const’ and ‘var’. https://github.com/ziglang/zig/issues/181
we could go back to using var
Not performance, just mutability safety.
In terms of performance the difference is minimal, if we get detailed `const` helps the compiler to optimize performance by ensuring that the reference remains constant, on the other hand ‘let’ minimally overloads the compiler as it must allow it to overwrite.
We would optimize more by cleaning the fans of the pc than with this 🤣🤣🤓
Depends on the language