[Solved] How are array methods aware of the values they are called on?


Array.prototype.mymap = function(callback) {
	var myArray = this; // here is the magic
	var newArray = [];
	for (var i = 0; i < myArray.length; i++) {
		newArray.push(callback(myArray[i]));
	}
	
	return newArray;
};

console.log([0, 1, 2, 3].mymap(a => a * 2));

2

solved How are array methods aware of the values they are called on?