<script language="jscript" type="text/javascript">
function A(str)
{
this.str=str;
this.SayHello=function()
{
alert(this.str);
}
this.SayHello2=function(s)
{
alert(s);
}
}
function B(strb)
{
//第一种方法,对象冒充
this.SayHelloB=A;
this.SayHelloB(strb);
delete this.SayHelloB;
// //第二种方法 call方法
A.call(this,strb);
//第三种方法 apply方法
A.apply(this,new Array(strb));
}
//第四中方法 原型链
B.prototype=new A();
var obja=new A("i'm a");
obja.SayHello();
var objb=new B("i'm b");
objb.SayHello2("i'm hello2");
objb.SayHello();
</script>