2
*/
3
var p=new Employee('mxh',20);

1
function Person(name)
2

{
3
this.name=name
4
}
5
Person.prototype.sayHello=function()
6

{
7
alert(this.name);
8
}
9
function Employee(name,age)
10

{
11
Person.call(this,name);
12
this.age=age;
13
}
14
Employee.prototype=new Person();//将Employee的prototype设置为Person的prototype,并用Employee.prototype作为this调用Person函数
*/
3
var p=new Employee('mxh',20);
Code
1
function Person(name)2


{3
this.name=name4
}5
Person.prototype.sayHello=function()6


{7
alert(this.name);8
}9
function Employee(name,age)10


{11
Person.call(this,name);12
this.age=age;13
}14
Employee.prototype=new Person();//将Employee的prototype设置为Person的prototype,并用Employee.prototype作为this调用Person函数