为什么JavaScript中的参数前面没有var关键字? [英] Why are arguments in JavaScript not preceded by the var keyword?
本文介绍了为什么JavaScript中的参数前面没有var关键字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这可能是一个愚蠢的问题,但为什么JavaScript中的函数参数前面没有var关键字?
This may be a silly question, but why are function arguments in JavaScript not preceded by the var keyword?
为什么:
function fooAnything(anything) {
return 'foo' + anyThing;
}
而不是:
function fooAnything(var anything) {
return 'foo' + anyThing;
}
我觉得答案是,因为那是什么规范
但仍然......
I have a feeling the answer is because that's what the Spec says
but still...
推荐答案
这将是<$的多余用途c $ c> var 关键字。出现在函数名称声明后面的括号中的项目是函数的显式参数。
It would be a redundant use of the var
keyword. Items that appear in the parentheses that follow a function name declaration are explicitly parameters for the function.
这篇关于为什么JavaScript中的参数前面没有var关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文