Tan*_*nes 6 javascript asynchronous node.js node-async async.js
我使用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
}
}
Run Code Online (Sandbox Code Playgroud)
如果在上面,我可以在其他内部使用"继续"等效吗?这在技术上不属于循环,所以继续不起作用.
因为它只是一个功能,你应该能够return从它具有相同的效果:
else if (!response.results) {
return;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4680 次 |
| 最近记录: |