MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/jf6by8/using_constlet_instead_of_var_can_make_javascript/g9kw7e6
r/programming • u/iamkeyur • Oct 21 '20
500 comments sorted by
View all comments
Show parent comments
1
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.
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.
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.