What are loops?
for: Looping specific number of times based on item position
for of: Iteration based specific item in array.
for in: Iteration based on key value (Properties) of object.
while: Iteration till specific criteria is met.
do while: Iteration till specific criteria is met but criteria is specified separately.
For skipping further execution of code block you can use continue. After continue, loop will exit current execution but will continue with next item in iteration. For complete exit of iteration, you can use keyword break.
Looping an Array
Array.filter: Will iterate all the items in array and returns item which are returned true
Array.map: Will iterate all the items in array (will ignore null) but will return a new instance.
Array.reduce: Will iterate all the items in array, but will pass previous value to current execution block. For example if the output of previous execution is 10, 10 will be passed to next execution block. Please note output of array.reduce will be a single item.
Array.forEach: Will iterate all the items in array.