Please refer - http://jsfiddle.net/sf4oaxun/
function a() {
this.say = function () {
alert("hello");
};
}
a.prototype.what = function () {
alert("234234");
};
function b() {}
//b.prototype = Object.create(a);
//b.prototype = a;
var b1 = new b();
b1.say();
- The 2 commented lines, are they different?
Why does say not get invoked, and errors out when using either of the commented lines(please uncomment it)
b.prototype = Object.create(a); b.prototype = a;
- Quick question added - If 'b' is inheriting from 'a' using b.prototype = Object.create(a.prototype), then would instances of b not be able to call any method of a which is not defined on a's prototype? Please refer - jsfiddle.net/sf4oaxun/3