function Parent(hello)
{
this.hello = hello;
}
Parent.prototype.sayHello = function () {
alert(this.hello);
};
function Child(hello,word)
{
Parent.call(this,hello);
this.word = word;
}
Child.prototype = new Parent();
Child.prototype.sayWord = function ()
{
alert(this.word);
};
var child = new Child("hhh","233");
child.sayHello();
{
this.hello = hello;
}
Parent.prototype.sayHello = function () {
alert(this.hello);
};
function Child(hello,word)
{
Parent.call(this,hello);
this.word = word;
}
Child.prototype = new Parent();
Child.prototype.sayWord = function ()
{
alert(this.word);
};
var child = new Child("hhh","233");
child.sayHello();
child.sayWord();
注:推荐使用这个方式(父子对象属性和方法互补干扰)