So I'm runn开发者_StackOverflow中文版ing JSLint on the lastest version of jQuery available at bit.ly/jqsource. I've made the tests as lax as possible, but I still get errors. One of them is "Use a named parameter" on line 327:
target = arguments[0] || {},
What does it mean? Even this blog post doens't provide information.
It means that the code is accessing the parameter using the arguments
collection instead of a parameter specified in the function signature:
You can reproduce the error message with this code:
function x(a) {
var b = arguments[0];
}
Using the named parameter gives the same result without the lint error:
function x(a) {
var b = a;
}
I'll assume it actually says "Use a named parameter" instead of "variable".
If so, there can be a performance hit in some browsers when you reference the arguments
object. I'd guess that's what it's complaining about.
Some browsers will optimize away the creation of the arguments
object if it is never referenced.
精彩评论