相关疑难解决方法(0)

'call'如何在javascript中工作?

我在javascript中有一个关于'call'的问题.

var humanWithHand = function(){
    this.raiseHand = function(){
        alert("raise hand");
    }
}

var humanWithFoot = function(){
    this.raiseFoot = function(){
        alert("raise foot");
    }
}

var human = function(){

    humanWithHand.call( this );
    humanWithFoot.call( this );

}

var test = new human();
Run Code Online (Sandbox Code Playgroud)

所以..当我使用'call'作为humanWithHand.call(this)时,内部会发生什么?

humanWithHand变量(或点?)将其属性和成员复制到人类变量的原型中?

javascript call

9
推荐指数
2
解决办法
2311
查看次数

标签 统计

call ×1

javascript ×1