For example, say I want to do something with data from a bunch of urls. Let's say I put those urls in an array. Is it bad practice/wrong to do
for (let i = 0; i < urls.length; i++) {
http.get(url[i], (response) => {
// do something ...
})
}
Basically, I want to know how this code works. Does the for loop wait for each get request to complete before incrementing i or does it do the async thing of not waiting and continuing with the program?
Thanks.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment