goog.inherits() sets the prototype chain from the child constructor to the parent constructor.
goog.inherits = function(childCtor, parentCtor) {
function tempCtor() {};
tempCtor.prototype = parentCtor.prototype;
childCtor.superClass_ = parentCtor.prototype;
childCtor.prototype = new tempCtor();
childCtor.prototype.constructor = childCtor;
};
""
(.. , this). goog.inherits()
,
. , .
var Parent = function(name) {
this.name_ = name;
}
var Child = function(name) {
Parent.call(this, name);
}
goog.inherits(Child, Parent);
goog.base() - ,
call() apply().
[goog.base()] , 1-N.
, . , . 2-N.
, goog.inherits .
Closure goog.base()
.
var Child = function(name) {
goog.base(this, name);
}
goog.inherits(Child, Parent);