function ReadStream() {
stream.Readable.call(this);
}
util.inherits(ReadStream,stream.Readable);
------------------------------
var util = require('util'); var ConstructorA = function () { this.func1 = function () { console.log('im func1!!'); } }; ConstructorA.prototype.func2 = function () { console.log('im func2!!'); }; var ConstructorB = function () { //ConstructorA.call(this); }; util.inherits(ConstructorB, ConstructorA); var conb = new ConstructorB(); conb.func2();//正常。若是util.inherits(ConstructorB, ConstructorA);被注释了,这句将报错 conb.func1();//报错,上面ConstructorB里面注释的一行打开事后,这里就不报错了。
不掉用 父类的构造方法 只能继承原型链上的属性。无法仿问 函数内定义的内部属性。