Why does goog.inherits
from the Google Closure Library look like this:
goog.inherits = function(childCtor, parentCtor) {
function tempCtor() {};
tempCtor.prototype = parentCtor.prototype;
childCtor.superClass_ = parentCtor.prototype;
childCtor.prototype = new tempCtor();
childCtor.prototype.constructor = childCtor;
};
rather than
goog.inherits = function(childCtor, parentCtor) {
childCtor.superClass_ = parentCtor.prototype;
childCtor.prototype = new parentCtor();
childCtor.prototype.constructor = childCtor;
};
What benefit does tempCtor
provide?