r/javascript • u/websitegenius • Apr 30 '16
question How much performance does using const with ES6 gain you?
It seems that the general consensus of people writing ES6 is to use const for variables that won't change in value, which principally I can't disagree with.
But sometimes I wonder how much that really gains your application from a performance standpoint. If someone tries to reassign a const somewhere in the app that truly shouldn't be reassigned, the value there is clear. But if we're talking in terms of pure processing speed, does it make a difference?
Let's say in the worst-case scenario, I replaced all instances of const in your app with let (or even var), and run a million iterations of the most complex function affected by this. What would change? Would it run any slower? Any difference for server-side code vs. client-side?
Just wondering this from a curiosity standpoint. I'm not against const in any way, would just like to know what it gains you besides the type of bug prevention it can possibly give in other programming languages.
-4
u/saadq_ Apr 30 '16
I don't know about performance but I've started to get annoyed with having to type the five letter
consteverywhere. I wish they had used something likevalinstead. I've been considering just saying screw it and usingleteverywhere instead.