数组长度为4,当我运行循环3时,它运行正常,没有任何错误。但是当我运行4次for循环时,它会出错。
for(var userI=0;userI<userArray.length;userI++) {
var userEmail = userArray[userI].UserEmail;
var userFName = userArray[userI].FirstName;
var userMName = userArray[userI].MiddleName;
var userLName = userArray[userI].LastName;
//Check for the user and create the user if the user is not created.
(function (uEmail,uFName,uMName,uLName) {
logger.info("FirstName inside the function::"+tFName);
//Check and create user
queryUserEmail(uEmail).then(function (checkFlag) {
if (checkFlag === true) {
//User already Exists, Log it
logger.info('User '+uEmail+' already Existed');
} else {
CreateClassElements.click();
//Now create user
createUserPage.createUser(uEmail,uFName,uMName,uLName);
};
//Clear the element
emailQueryElement.clear();
});
}(userEmail,userFName,userMName,userLName));
};
当我在没有 queryUserEmail 功能的情况下运行循环时,它可以正常运行4次
for(var userI=0;userI<userArray.length;userI++) {
var userEmail = userArray[userI].UserEmail;
var userFName = userArray[userI].FirstName;
var userMName = userArray[userI].MiddleName;
var userLName = userArray[userI].LastName;
//Check for the user and create the user if the user is not created.
(function (uEmail,uFName,uMName,uLName) {
logger.info("FirstName inside the function::"+uEmail);
}(userEmail,userFName,userMName,userLName));
};
任何建议?