Javascript: for | for of | for in | forEach

preview_player
Показать описание
I go through all the fors. Regular for loop, the for of, the for in and finally the forEach. Giving examples of how to use each. I also talk about the differences between them and why I can't stand using forEach ever in my projects. Check out the for await documentation I found below as well!

My channel membership is live check it out here!:

Membership perk video:

Check out my channel @ConsultingNinja for more videos like these.

Link to codepen:

Javascript Docs:

Standard for loop Docs:

for ... of Docs:

for ... in Docs:

forEach Docs:

I also found this for await, has anyone seen this used in anything anywhere? Please comment if you have!:
Рекомендации по теме
Комментарии
Автор

Merry Christmas!
for of, and for in loops are in my opinion dangerous to use. For example if you use them to iterate in an object, it will not only iterate the elements of the object but also all the elements of the parent ( through inheritance) objects.
My personal bad experience with for ... of/in:
I used them to iterate a 2-D array in a coding interview test and I had problems and I lost a lot of time to debug it. Then I used the old classic for and all problems solved. It was pity to loose the job or take lower salary for that reason. Also, I was in the exactly same occasion when I took the test for the hackerank problem solving certification. I lost a lot of time and I failed in the test.
I still don't know why the for of loop didn't worked. The lesson for me was that in the coding interviews, not to use for...of/in loop, but the old classic for

dimitmoto