« flate | 首页 | pongba »
在 Javascript面向对象编程(二):构造函数的继承 留言:
function Animal() { this.species = "动物"; } function Cat(name, color) { this.name = name; this.color = color; } function extend(Child, Parent) { var F = function() { }; F.prototype = Parent.prototype; Child.prototype = new F(); Child.prototype.constructor = Child; } extend(Cat, Animal); var cat1 = new Cat("大毛", "黄色"); alert(cat1.species); // 结果是undefined\ 取不到"动物" 值
2012-01-04 11:47:35
Child.uber = Parent.prototype; 这样写有什么好处... 不是很理解
2011-12-28 14:17:01
在 【活在中国】谁是恶意软件? 留言:
我现在比较喜欢用360杀毒软件。
2010-02-07 14:21:02
在 我要翻译Paul Graham了 留言:
期待你的作品,加油!
2009-12-28 16:52:22
在 卡尔维诺中文站留言板 留言:
去年看了这个网站,今年再来的时候,风格一新,别样的感受。。。。。祝您的网站越办越好
2007-06-07 21:00:16
留言(5 条)
在 Javascript面向对象编程(二):构造函数的继承 留言:
function Animal() {
this.species = "动物";
}
function Cat(name, color) {
this.name = name;
this.color = color;
}
function extend(Child, Parent) {
var F = function() { };
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.prototype.constructor = Child;
}
extend(Cat, Animal);
var cat1 = new Cat("大毛", "黄色");
alert(cat1.species); // 结果是undefined\
取不到"动物" 值
2012-01-04 11:47:35
在 Javascript面向对象编程(二):构造函数的继承 留言:
Child.uber = Parent.prototype;
这样写有什么好处... 不是很理解
2011-12-28 14:17:01
在 【活在中国】谁是恶意软件? 留言:
我现在比较喜欢用360杀毒软件。
2010-02-07 14:21:02
在 我要翻译Paul Graham了 留言:
期待你的作品,加油!
2009-12-28 16:52:22
在 卡尔维诺中文站留言板 留言:
去年看了这个网站,今年再来的时候,风格一新,别样的感受。。。。。祝您的网站越办越好
2007-06-07 21:00:16