Back in the days loops was a tough topic for me so I dedicate this post to all of you, people who struggle, so that you will, at least a bit better understand the different loops that #javascript has! ๐โบ
Functional vs standard approach
The standard approach is to use a loop statement (one of the 5 described) to loop over an object.
There's nothing wrong with it but it's not the best way.
Nowadays, people are switching to a better way of iteration/looping which is the functional way.
That is to say for example .forEach() .map( ) .reduce() .filter() and etc. array methods. Those are, again, used for iteration but it's in a functional approach. What I love about it is that you can chain the methods together - For example, this expression ["a", "b", "ab", "c"].map(str => str.toUpperCase()).filter(str => str.length < 2) would convert all strings to uppercase and then leave in the array only those who's length is less than 2. Result: ["A", "B", "C"].
โก๏ธ Now a challenge for you: Write down in the comments code that does the same but without using the functional approach.
See the difference? That's why the functional approach is my favorite one.
However, it wouldn't be possible without the standard approach it steps on: What do you think is behind those iteration methods..?
Of course standard loops, which are more generic but open way more possibilities: You use the for loop for whatever you want but .filter() only in limited number of situations.