Itβs clear that in Firefox:
var foo = function() {} foo.__proto__ == Function.prototype;
is true , while the statements are:
console.log.__proto__ == Function.prototype; console.log instanceof Function;
are false .
Therefore, console.log does not include Function.prototype in its prototype chain, so changing Function.prototype does not affect console.log . This is fine because console is a host object (and not a native object in the ECMAScript specification) and can behave, however, by Mozilla (or Google or Microsoft, etc.).
Why does this behavior exist? I am not a Firefox developer, so I canβt say for sure, but I think it was done on purpose, because console is a debugging tool. If you cheat on the Function prototype chain and then want to use console.log to check what you are doing, it would be terrible if your debugging reporting tool started to get confused and distort something for you.
EDIT:
The console functions have a separate prototype chain used by all of them:
console.log.__proto__ == console.dir.__proto__ // true console.log.__proto__.func = 5; console.dir.__proto__.func == 5 // true
source share