Subj : Re: Method added into Object.prototype: can't call directly inside To : Lev Serebryakov From : Brendan Eich Date : Mon Oct 03 2005 12:06 pm Lev Serebryakov wrote: > This code works in JavaScript shell & JavaScript environment (provided > by Extension Developer Extension), but doesn't work in script, loaded > into XUL file (XUL file is in "chrome://" space) with "XXX.aha is not a > function" error: > > Object.prototype.aha = function() { window.dump("aha\n"); } > function XXX() {}; > XXX.aha(); > > This works everywhere: > > Object.prototype.aha = function() { window.dump("aha\n"); } > function XXX() {}; > XXX.prototype.aha.apply(XXX); > > Why first variant doesn't work in XUL context? :( Second variant is too > ugly to use... What is XXX, exactly? I bet you are not using the same XXX in the js shell, because XXX is a DOM or XPCOM object of some kind. /be .