Question

taking a standard browser as example,

there is the Window class instantiated as window variable

window variable also contains the Window constructor (window.Window)

test this in your (standard) browser:

alert(window instanceof window.Window);

var asd = function(){};
asd.prototype.test = asd;
var x = new asd();
alert(x instanceof x.test);

now, window is also instanceof EventTarget that is stored in window.EventTarget

how to inherit EventTarget in the window object?

Was it helpful?

Solution

I'm answering to myself :|

var EvtTarg = function(){};
EvtTarg.prototype.justATest = function(){alert("asd");};

var Win = function(){};
Win.prototype = Object.create(EvtTarg.prototype);
Win.prototype.EvtTarg = EvtTarg;
Win.prototype.Win = Win;

var win = new Win();
alert(win instanceof win.Win);
alert(win instanceof win.EvtTarg);

there is a better way to do this?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top