我正在使用 node.js 异步包,特别是 forEachSeries,根据从数组中提取的参数发出一系列 http 请求。在每个请求的回调中,我有一些 if/else 语句来响应不同类型的响应。
// This is the callback of a GET request inside of a forEachSeries
function(error, response) {
if (response.results) {
// Do something with results
}
else if (!response.results) {
// Would like to use a continue statement here, but
// this is not inside of a loop
}
else {
// Do something else
}
}
是否有等同于“continue”的等价物,我可以在上面的 else 中使用?这在技术上不在循环内部,因此 continue 不起作用。
最佳答案
因为它只是一个函数,所以您应该能够从它返回
以产生相同的效果:
else if (!response.results) {
return;
}
关于javascript - 使用 node.js async forEachSeries 时是否有与 'continue' 等效的语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10106667/