How to execute JavaScript concurrently while specifying the number of concurrent executions

There are times when you have many tasks that you want to process in parallel, but executing all of them in parallel would be too heavy, so you want to specify the number of tasks to be executed concurrently. I am ashamed to admit that I did not know how to do this in JavaScript, but as an alternat…