日期:2014-05-16  浏览次数:20348 次

请问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()