Skip to content

Commit

Permalink
Update 151.implement-Array-prototype-map.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaban-Eissa authored Jun 7, 2024
1 parent ff16431 commit 17674e2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 151.implement-Array-prototype-map.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ This JavaScript code is a custom implementation of the `Array.prototype.map()`fu

Here's a breakdown of the code:

1. `Array.prototype.myMap = function (callback, thisArg) {...}` This line is extending the Array prototype with a new method called `myMap`. This method takes two arguments: a `callback` function and an optional `thisArg` object that will be used as `this`] when executing the callback.
1. `Array.prototype.myMap = function (callback, thisArg) {...}` This line is extending the Array prototype with a new method called `myMap`. This method takes two arguments: a `callback` function and an optional `thisArg` object that will be used as `this` when executing the callback.

2. `const length = this.length;`: This line is storing the length of the array on which `myMap` was called. This is done to avoid potential infinite loops if the array's length is changed during the execution of `myMap`.

Expand Down

0 comments on commit 17674e2

Please sign in to comment.