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