Created
February 7, 2019 11:26
-
-
Save bitfishxyz/fac4e911c99761b2f357fb3788e261dc to your computer and use it in GitHub Desktop.
Imitation of Function.prototype.call
This file contains 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
Function.prototype.myCall = function(thisArgs) { | |
thisArgs.$fn = this // | |
let args = [] | |
for(let i = 1; i<arguments.length; i++){ | |
args.push(arguments[i]) | |
} | |
var result = thisArgs.$fn(...args) | |
delete thisArgs.$fn | |
return result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment