function callAnotherFunc(fnFunction,vArgument){
fnFunction(vArgument);
}
var doAdd = new Function("iNum","alert(iNum + 10)");
callAnotherFunc(doAdd,10);
这段代码有点模糊,能具体解释一下吗?
function callAnotherFunc(fnFunction,vArgument){
fnFunction(vArgument);
}
var doAdd = new Function("iNum","alert(iNum + 10)");
callAnotherFunc(doAdd,10);
这段代码有点模糊,能具体解释一下吗?
var doAdd = new Function("iNum","alert(iNum + 10)");
这一句生成一个函数对象,相当于
[code="js"]
var doAdd = function(iNum){
alert(iNum + 10);
}
[/code]
callAnotherFunc(doAdd,10);
这句调用callAnotherFunc函数,并把doAdd 和10作为参数传递给他,
[code="js"]
function callAnotherFunc(fnFunction,vArgument){
fnFunction(vArgument);
}
[/code]
不就是等于doAdd(10);嘛? :D