Question 13
Back to Exercise
How many times does [1, , 3].forEach(fn) call fn?
- A 3 – the hole is passed as undefined
- B 2 – forEach skips the hole Correct
- C 1
- D 0 – sparse arrays cannot be iterated
Correct Answer: Option B
forEach, map, filter, reduce and for…in skip holes. A classic for loop and for…of visit index 1 and read undefined.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!