My Code is Simple
var core ={
f: function(obj){
console.log(toString.call(obj));
}
}
Which should display [object Function]
if I pass another function to it like core.f(function(){}),
and it does the same if I paste the core.f in Chrome inspector.
But that anonymous function becomes [object Object] if the core.f is loaded through a script with <script src>
If you’re testing in a console, they probably have a local
toStringthat resolves toObject.prototype.toString.You should make your own local reference if you don’t want the full prototype path.
In Chrome, I show a different
toStringthanwindow.toString…The
toStringreference does successfully resolve toObject.prototype.toString……so you can see that they’ve created their own local reference that shadows the global.