A bit ago I was working with Object.entries and wasn’t seeing the functionality I expected. I kept staring, and staring and finally realized I was using “for in" instead of "for of".
Just spent a long time staring at a code snippet that wasn’t working. Note that both statements below are valid JS…that result in very different functionality!
15:48 PM – 02 Jul 2019
And that got me thinking I should write a post to talk about the differences. So here we are!
for…in and for…of are substitutions for a traditional for loop. It’s quite common to need to do something like this.