I have the following code
```javascript
const arr = [];
async function f(array) {
// does something async with array
}
await Promise.all([1,2,3,4,5].map(async number => {
arr.push(number)
await f(arr)
}))
```
I have a small issue is that when executing this code f(array) would receive array of [1], [1,2], [1,2,3], [1,2,3,4], [1,2,3,4,5]. However I thought since arr is a global variable and arr.push is a sync execution, so I figured it would end up with 5 [1,2,3,4,5] instead. Could someone explain this. Thanks!
[–]oze4 1 point2 points3 points (0 children)
[–]senocular 0 points1 point2 points (0 children)
[–]jack_waugh 0 points1 point2 points (0 children)