Loading problem…
Implement Array.prototype.myMap — a polyfill that behaves like native Array.prototype.map.
Mapping is a foundational skill in JavaScript interviews, but many implementations miss important details: sparse arrays (holes), callback arguments, thisArg binding, and mutation behavior during iteration.
arr.myMap(callbackFn, thisArg?) returns a new array.callbackFn once per existing element in the array (skip holes).(value, index, array) to the callback.thisArg binds the callback this (non-arrow callbacks).TypeError if callbackFn is not a function.