![](/img/trans.png)
[英]What is the difference between (function(){})(); and (function(){}());?
[英]What is the difference between these function callings?
所以我想知道这些之间有什么区别:
var a=5;
var b=3;
function asd(a,b) {
a=a+b;
b=b-a;
}
function asd2(){
a=a+b;
b=b-a;
}
function asd3(var a, var b){
a=a+b;
b=b-a;
}
很抱歉这个question脚的问题,但不知道如何使用Google:S。
第一个从函数参数中获取参数,
第二个采用全局定义的变量。
第三应该不起作用。
我希望这不是一个家庭作业问题,但我会为您指明正确的方向。
输出是什么:
asd(123,456);
你能改变输出吗
asd2();
如果是这样,怎么办?
告诉asd()和asd3()之间的区别,请尝试以下操作:
var c=10;
var d=4;
alert (asd(c,d));
alert ("c is " + c + " and d is " + d);
与
var c=10;
var d=4;
alert(asd3(c,d));
alert ("c is " + c + " and d is " + d);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.