您现在的位置是:首页 > 电脑技术查询 > web开发

请教Prototype中的Class类中的apply用发是什么意思

编辑:chaxungu时间:2022-10-02 23:23:01分类:web开发

请问Prototype中的Class类中的apply用发是什么意思?
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
};
var vehicle=Class.create();

vehicle.prototype={
initialize:function(type){
this.type=type;
},
showSelf:function(){
alert( "this vehicle is "+this.type);
}
}

var moto=new vehicle( "Moto ");
moto.showSelf();

其中this.initialize.apply(this, arguments);在什么时候运行,此处的this是哪个对象?

------解决方案--------------------
在 var moto=new vehicle( "Moto ");的时候运行
this指的是 Class()