I am implementing the map function. To access the array I am mapping over I am using this based on a question I had earlier. Now I am wondering how to access different arguments passed to the callback. So in the official map method you can pass the index. I am trying to do this, but unsure how to access this in my custom method.
Array.prototype.mapz = function(callback) {
const arr = [];
for (let i = 0; i < this.length; i++) {
arr.push(callback(this[i]))
}
return arr;
};
let x = [1, 12, 3].mapz((item, index) => {
return item * 2;
})
console.log(x);
index?