
We have the event queue, which stages events in a First In First Out queue. The diagram above describes how the JavaScript event loop works.

Modern websites and web apps need to do multiple operations at a time, so how does that work? The event-loop makes this possible by sharing the single thread which is available to the browser's window. Since JavaScript is single-threaded, we only have 1 operation running at a time. In order to understand the scalability in JavaScript, we need to first understand how JavaScript works at the core: the event loop and event queue. When we compare this to our filter example, it is confined to a single line, which has all the logic needed. Or the for-loop way of solving the problem: const threes = This is a perfect use case for the filter method: const threes = items.filter(item => item.length = 3) Here is one example of the types of loops we will be comparing today: const items = There are a few metrics we will consider when comparing the methods in the Array class, to the “old” for-loop way of doing things: performance, readability, and scalability. We are all used to the clean code that Array.map and Array.filter provide us, but for your real world applications, are regular for loops better than these convenient methods?
