// 类的继承
function Person(name,age){
this.name = name;
this.age = age;
this.alertName = function(){
console.log(this.name);
}
this.alertAge = function(){
console.log(this.age);
}
}
function webDever(name,age,sex){
Person.call(this,name,age); //Person.apply(this,arguments);
this.sex = sex;
this.alertSex = function(){
console.log(this.sex);
}
}
var webtest = new webDever("Jon",20,"male");
webtest.alertAge(); //20
js call与apply
最新推荐文章于 2022-03-07 11:20:14 发布