TypeError: variable "x" redeclares argument (Firefox)
TypeError
warning in strict mode only.
The same variable name occurs as a function parameter and is then redeclared using a var
assignment in a function body again. This might be a naming conflict and thus JavaScript warns about it.
This error occurs as a warning in strict mode code only. In non-strict code, the redeclaration is silently ignored.
In this case, the variable "arg" redeclares the argument.
'use strict'; function f(arg) { var arg = 'foo'; }
To fix this warning, the var
statement can just be omitted, because the variable exists already. In other cases, you might to rename either the function parameter or the variable name.
'use strict'; function f(arg) { arg = 'foo'; }
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Var_hides_argument