将函数参数重新声明为变量? [英] Redeclaring function parameters as variables?

查看:43
本文介绍了将函数参数重新声明为变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在网络"上的任何地方找到答案...

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?

示例:

function(param1, param2) {
  var param1, param2;
  ...etc...
}

对我来说似乎非常多余,但也许我遗漏了什么......?

Seems extremely redundant to me, but maybe I'm missing something...?

谢谢,

布莱恩

推荐答案

如果声明的变量名称与函数参数的名称相同,那么它绝对没有任何作用.完全没有价值.甚至不改变变量的值.

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.

这篇关于将函数参数重新声明为变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆