Call super constructor (closure compiler and library)

332 views Asked by At

Using the Google closure compiler and library for inheritance I found two different calls of super constructor in a lot of closure based libraries (forgot where I found it). Not sure if I got it wrong at all.

What is the difference and what is the correct one to use?

// Xhrio extends EventTarget
goog.events.EventTarget.call(this);
goog.net.XhrIo.base(this, 'constructor');
1

There are 1 answers

1
Tyler On BEST ANSWER

Either one is fine. I suppose you might say the second one is slightly better because if you later changed XhrIo to extend something other than EventTarget you might not have to change that line.

You can also use goog.base(this, 'constructor') but that is incompatible with strict mode.