如何获取函数参数值
How to get the function arguments value?
我想通过使用arguments[I]循环所有函数arguments值来简化我的电子邮件验证,但它返回"undefined"。
function checkInputRequired(companyNameValue, contactNameValue, publisherEmailValue, publisherEmailConfirmValue)
{
// The arguments object is an Array-like object corresponding to the arguments passed to a function.
for (var i = 0; i < arguments.length; i++)
{
// print out 4 undefined
console.log(arguments[i]);
}
}
检查
function checkInputRequired(companyNameValue, contactNameValue, publisherEmailValue, publisherEmailConfirmValue)
{
// The arguments object is an Array-like object corresponding to the arguments passed to a function.
for (var i = 0; i < arguments.length; i++)
{
// print out 4 undefined
console.log(arguments[i]);
}
}
checkInputRequired('ddd','bbbbb','sssss','dddddddddd');
当您调用该函数时,它将显示值,否则它将显示未定义的默认值。
相关文章:
- 函数参数中的数据与指定变量之间的任何性能差异
- AngularJS:我可以跳过函数参数回调吗
- 为什么不'我们在javascript中使用函数参数的数据类型
- 使用闭包共享构造函数参数
- 函数参数的值错误
- 当一个重要的构造函数参数丢失时应该发生什么
- 阻止ReSharper将JavaScript函数参数放到新行中
- 根据函数参数将CSS值存储在var中,然后对其进行操作
- 使构造函数参数具有ES6类方法的特权
- 当客户端将两个按钮的javascript函数参数修改为相同时,SQL/PHP会更新多行
- Windows.Networking.EndpointPair构造函数参数
- 是否可以使用Sinon.JS检查函数参数绑定是否正确
- 大括号中的Javascript函数参数
- jQuery 无法使用 AJAX 调用访问函数内部的函数参数
- 将JSON字符串转换为函数参数
- eval()读取函数参数有多糟糕
- Javascript不能在一个命令中使用函数参数
- 函数参数在内部不可见,返回新的Promise(函数(resolve,reject).传递给被promise化的函数的
- ES6类构造函数参数
- 是否可以在javascript函数参数列表中调用多个函数