Last active
May 26, 2019 20:34
-
-
Save funador/fca9277ad8da161c985d437349ce0586 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Array.prototype.myMap = function(callback) { | |
| const arr = [] | |
| for (let i = 0; i < this.length; i++) { | |
| arr.push(callback(this[i], i , this)) | |
| } | |
| return arr | |
| } | |
| const nums = [1, 6, 8] | |
| console.log(nums.myMap(num => num * 2)) // [ 1, 12, 16 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment