Created
January 19, 2020 01:06
-
-
Save bitfishxyz/f11728098e6cd8ac8ef49f6c03771788 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
const selfMap = function (fn, context) { | |
let arr = Array.prototype.slice.call(this) | |
let mappedArr = Array() | |
for (let i = 0; i < arr.length; i++) { | |
if (!arr.hasOwnProperty(i)) continue; | |
mappedArr[i] = fn.call(context, arr[i], i, this) | |
} | |
return mappedArr | |
} | |
Array.prototype.selfMap = selfMap; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment