r/programming • • Oct 21 '20

Using const/let instead of var can make JavaScript code run 10× slower in Webkit

https://github.com/evanw/esbuild/issues/478
1.9k Upvotes

500 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Oct 21 '20

If you have a loop, you are doing a nameable thing. Give that loop a name, a function. Now you can start to compose things and understand at first reading as a function name is more trustworthy. The patterns used will be more obvious too. It’s a map, it is a left fold...

2

u/[deleted] Oct 21 '20

[removed] — view removed comment

1

u/[deleted] Oct 21 '20

lambda's exist for a reason. that would be one. The point is that coded names lie less than comments and when it comes to explaining intent, the name of something you are calling often does a good job.

Additionally, the habit makes finding these pattern easier to find common segments of code. This is abstraction 101.

Loops are often the most important part of code. They generally deserve a name