为什么没有类jordan
的属性Human
?难道说所有类都继承类的所有属性Coder.prototype = new Human;
就足够了吗?Coder
Human
它与将功能定义为分配有关吗?
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);