In Function.prototype page in MDN says that the Function.prototype cannot be modified". But when I tried the following code in the console, it proved me that you can modify the existing properties of the Function.prototype, as well as we can add new properties to it.
Function.prototype.call = function(context) {
console.log("call() fn has been modified");
};
var f = function() {
//do something..
};
f.call(this);
and it shows the following as the result in the console.
call() fn has been modified
If the Function.prototype cannot be modified, why I am seeing such a behavior?
this question refers to the same problem. But there what has been modified is the 'AclassName.prototype'. not the Function.prototype.
Function.prototype is not Function.prototype.call, normally you can do SomeConstructor.prototype = { ... }, but you cannot do Function.prototype = { ... }.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With