<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tessa Serdar on Medium]]></title>
        <description><![CDATA[Stories by Tessa Serdar on Medium]]></description>
        <link>https://medium.com/@tessaserdar?source=rss-297519533a71------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-uM6UWW2FdKO0msikBNUTw.png</url>
            <title>Stories by Tessa Serdar on Medium</title>
            <link>https://medium.com/@tessaserdar?source=rss-297519533a71------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 14:26:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tessaserdar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What is the event loop?]]></title>
            <link>https://medium.com/@tessaserdar/what-is-the-event-loop-21ddca0c055e?source=rss-297519533a71------2</link>
            <guid isPermaLink="false">https://medium.com/p/21ddca0c055e</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Tessa Serdar]]></dc:creator>
            <pubDate>Wed, 08 Jun 2016 17:06:18 GMT</pubDate>
            <atom:updated>2016-06-08T17:06:18.229Z</atom:updated>
            <content:encoded><![CDATA[<p>Kyle Simpson’s explanation has always stuck with me for it’s simplicity.</p><blockquote>The event loop is the mechanism that handles executing chunks of your program over time.</blockquote><p>Now let’s take a high level look at the why and how.</p><h4>Why? Think Async.</h4><p>I now think of async as the gap between now and later. Most likely in any slightly advanced JS program, you are going to have code that runs now, and code that runs at some “later” time in your program execution. The event loop tells your JS program what to runs now and what runs later.</p><h4>How? Not in Isolation:</h4><p>The JS engine doesn’t run in isolation but instead runs inside a hosting environment( often the web browser). The JS engine does not have knowledge of time, but is instead acts as an on-demand execution environment for pieces of JS code. The surrounding environment handles the scheduling of events aka code execution.</p><h4>A quick example:</h4><p>Here is an quick example of some code that would run now and some that would run later. By wrapping the response handler into a function that should be executed upon an Ajax response, I’ve created a chunk of code to run later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*A_p-Ii9p9wGVOn-PRmfx4g.png" /></figure><p>At a very high level, here’s what happens if we ran this hypothetical piece of code: First we make our ajax call, then this will move off the call stack. Once we get a response to the Ajax request, the doThisWhenResponse function is added to the event queue. The event-loop will look at the state of the call stack, when the stack is empty it takes the first thing in the event queue and pushes it onto the stack to be executed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21ddca0c055e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>