function Foo(){ /*some attributes and methods here*/ }
function Bar(){}
比如声明了Foo之后,想让Bar继承它,好像有两种方法:
1. Bar.prototype = new Foo();
2. Bar.prototype = Foo.prototype;
这两种方法是完全等价的吗?还是有啥细微差别?
function Foo(){ /*some attributes and methods here*/ }
function Bar(){}
比如声明了Foo之后,想让Bar继承它,好像有两种方法:
1. Bar.prototype = new Foo();
2. Bar.prototype = Foo.prototype;
这两种方法是完全等价的吗?还是有啥细微差别?