Problem, as an interviewer would state it:
"Implement Array.prototype.myFilter from scratch — matching real native filter's own documented contract, including its real hole-skipping behavior on a sparse array."
Examples:
[1,2,3,4,5,6].myFilter(n => n % 2 === 0); // [2, 4, 6]
Clarifying questions expected:
- Does the callback receive the index and whole array, matching real native's own documented signature?
- Should a real hole in a sparse array be skipped entirely — never invoking the callback, and never appearing in the result?
- Is the result a genuinely NEW array, or should it mutate the original?
Code / implementation expected: Yes — real, direct proof against the ACTUAL native filter, including on a real sparse array, confirming identical output.