nodejs for循环把一个i++赋给异步操作函数
nodejs需要循环把一个i++赋给异步操作函数里面,除了使用匿名函数让for循环先执行后,还有别的什么办法吗? for ( item in result[1]) { (function(item){ listResult[item] = getExpandStr(expandStr, result[1][item], tenantUUID).then(function (resultExpand) { for (var x in resultExpand) { if (resultExpand[x].tag == ‘bill’) { result[1][item].bills = returnResources.generateBillRetInfo(tenantUUID, resultExpand[x]) } if (resultExpand[x].tag == ‘groupMembership’) { result[1][item].groupMemberships = returnResources.generateGroupMembershipRetInfo(resultExpand[x]) } } return result[1][item]; }); }(item)); }