douglascrockford/JSLint — Issue #102: Feature request: Warn about parameter reassignment
Author: magnars
Created: 2012-02-17 15:03:39+00:00
State: open

While linting our project, I came across this gem:

function a() {
var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
}

JSLint wanted me to use an argument instead, so I switched it to:

function a(args) {
if (!$.isArray(args)) { args = arguments; }
}

And my tests failed. To me, these two functions looked equivalent. However, as I have now learned, reassigning parameters also changes the arguments-"array".

Maybe JSLint could warn about reassigning parameters? Possibly restricted to functions that also access `arguments`? Would have saved me quite a bit of time today at least.

Thanks for an excellent tool!