The doc of Array.prototype.forEach says:
forEach executes the provided callback once for each element of the array with an assigned value.
It is not invoked for indexes which have been deleted or which have been initialized to undefined.
Why?
Look at this console "experiment" I ran:
Image link
You can clearly see that Array.forEach does not skip undefined
values (that the key here). Only undefined
as in deleted will be skipped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With