我希望通过使用arguments [i]循环遍历所有函数参数值来简化我的电子邮件验证,但它返回“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]);
}
}
答案 0 :(得分:1)
检查出来
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');
当您调用该函数时,它将显示值,否则显示默认值undefined。