I can't seem to find an answer for this anywhere on the 'Net...
Is there any reason, advantage, or disadvantage to redeclaring function parameters as local variables?
Example:
function(param1, param2) {
var param1, param2;
...etc...
}
Seems extremely redundant to me, but maybe I'm missing something...?
Thanks,
Brian
If the names of the declared variables are the same as the ones as the function parameters then it does absolutely nothing. Completely worthless. Doesn't even change the value of the variable.
There is no good reason to ever redeclare a local variable with the same name as a parameter. Most languages wouldn't allow this, but JavaScript allows pretty much everything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With