call,

Function.prototype.myCall = function(currentContext = {}, ...arg) {

if (typeof this !== 'function') {
throw new Error(this + "it's not callable");
}
currentContext.fn = this;
currentContext.fn(...arg);

};

apply,

Function.prototype.myApply = function(currentContext = {}, arg = []) {
if (typeof this !== 'function') {
throw new Error(this + "it's not callable");
}

--

--

Sonika | Working at Walmart | startlearncoding.com

Sonika | Working at Walmart | startlearncoding.com

Working in Walmart as Senior UI Developer | React | JavaScript | Data Structure