DEV Community

Discussion on: Mastering Async Programming in TypeScript: Promises, Async/Await, and Callbacks

Collapse
 
brense profile image
Rense Bakker

Small but important note: asynchronous is not the same as concurrent. JavaScript is executed in a single thread, so you can only actively do one thing at a time. What promises allow you to do is avoid blocking execution of the rest of your code, while you wait for some event to happen (like a setTimeout for example). Promises wont allow you to do two things at the same time. For example if you want to loop through two arrays with loop A not blocking loop B, you can't do that, regardless of whether you do it inside a Promise or not. You can only concurrently execute code by using worker threads or webworkers.

Collapse
 
cliff123tech profile image
Isaiah Clifford Opoku

okay sir .Thank you for your feedback . Is noted