Skip to content

Commit c5b7a22

Browse files
author
abhishek.sat
committed
Add optional thisArg
1 parent 6a82bb9 commit c5b7a22

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

implementations/map.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
- the Array object being traversed
99
*/
1010

11-
Array.prototype.myMap = function(callback) {
11+
Array.prototype.myMap = function(callback, thisArg) {
1212
var mapArray = [];
1313
for (let i = 0; i < this.length; i++) {
14-
mapArray.push(callback(this[i], i, this));
14+
mapArray.push(callback.call(thisArg, this[i], i, this));
1515
}
1616
return mapArray;
1717
};

0 commit comments

Comments
 (0)