The
Function.prototype.call()
method calls the function with a giventhis
value and arguments provided individually.
Source: Function.prototype.call() - JavaScript | MDN
Implement your own Function.prototype.call
without calling the native call
method. To avoid overwriting the actual Function.prototype.call
, implement the function as Function.prototype.myCall
.
function multiplyAge(multiplier = 1) {return this.age * multiplier;}const mary = {age: 21,};const john = {age: 42,};multiplyAge.myCall(mary); // 21multiplyAge.myCall(john, 2); // 84
The
Function.prototype.call()
method calls the function with a giventhis
value and arguments provided individually.
Source: Function.prototype.call() - JavaScript | MDN
Implement your own Function.prototype.call
without calling the native call
method. To avoid overwriting the actual Function.prototype.call
, implement the function as Function.prototype.myCall
.
function multiplyAge(multiplier = 1) {return this.age * multiplier;}const mary = {age: 21,};const john = {age: 42,};multiplyAge.myCall(mary); // 21multiplyAge.myCall(john, 2); // 84
console.log()
statements will appear here.