javascript10.0(继承)
17. JavaScript中的继承。
1) 对象冒充
<html><head><script type="text/javascript">function Parent(hello) {this.hello = hello;}Parent.prototype.sayHello = function() {alert(this.hello);}function Child(hello, world) {Parent.call(this, hello);this.world = world;}Child.prototype = new Parent();Child.prototype.sayWorld = function() {alert(this.world);}var child = new Child("hello", "world");child.sayHello();child.sayWorld();</script></head><body></body></html>