您的位置:首页 > Web前端 > JavaScript

js中Function方法

2016-03-11 11:18 513 查看
function.apply(thisArg,argArray)

apply方法调用function,传递一个会绑定到this上的对象和一个可选的数组作为参数。

apply方法被用在apply调用模式中。

例如:

Function.method("bind",function(that){
var method=this,
slice=Array.prototype.slice,
args=Array.prototype.slice.apply(arguments,[1]);
return function(){
return method.apply(that,args.concat(slice.apply(arguments,[0])));
};
var x=function(){
return this.value;
}.bind({value:666});
alert(x());
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: