Why doesn't jordan
have the properties of the Human
class? Shouldn't saying Coder.prototype = new Human;
be enough for all Coder
classes to inherit all properties of the Human
class?
Does it have something to do with defining functions as assignments?
var Human = function() {
var hi = function() {
alert('hi');
};
return {
name : 'dan',
sayHi : hi
};
};
var dan = new Human();
var Coder = function() {
var code = function() {
alert('1010101');
};
return {
code : code
};
};
Coder.prototype = new Human;
Coder.prototype.constructor = new Coder;
var jordan = new Coder();
console.log(jordan);