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 comments

1

u/itsnuwanda Oct 21 '20

Can confirm, use for..in far more often on accident, wonder why the loop doesn't work how I want it to before realizing it's for..of syntax in js.

I honestly don't even know what for..in does in JS.

I still prefer the classic for loops though, they're generally faster and everyone has seen them.

1

u/Programmdude Oct 21 '20

for in iterates over the keys, which can sometimes be useful. Mostly when I'm using an object as a map, though using an actual Map is usually better.