DEV Community

Discussion on: Difference between for...of and for...in loop in JavaScript.

Collapse
 
msid01 profile image
Siddhesh Mungekar

You can remember it as
of - objects iterable
in - enumerable objects

I hope it won't be confusing 😃

Collapse
 
leob profile image
leob

Hmm yeah that might work ... I can't come up with anything better either lol

Thread Thread
 
drbatroni profile image
DrBatroni

I use it like this:
in - iterate in object
of - iterate over something (string/array)

Thread Thread
 
leob profile image
leob

Yes I like that! best one I've seen until now ...

Collapse
 
narayand16 profile image
Narayan Deshmukh

Thanks , this will really help !

Thread Thread
 
swastikyadav profile image
Swastik Yadav

I am glad that this helped, Narayan 😊