I'm trying to read and add multiple files to an array. I've already found out that readAsArrayBuffer is a asynchronous function, so i need to wait for previous uploads to end. I tried to use callbacks but i failed.

So now i have new FileReader each iteration, i got rid from Failed to execute 'readAsArrayBuffer' on 'FileReader': The object is already busy reading Blobs error, now i have the same files in my array, although I selected different.

Answer:1

Your issue is that reader is going to be clobbered - using .forEach will mean each iteration is safe in its own closure - no need for IIFE kludges either