<?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 Gia Edgington on Medium]]></title>
        <description><![CDATA[Stories by Gia Edgington on Medium]]></description>
        <link>https://medium.com/@gia.edgington?source=rss-bb1814e335f2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*hwLh3IpxW93rdVzg.</url>
            <title>Stories by Gia Edgington on Medium</title>
            <link>https://medium.com/@gia.edgington?source=rss-bb1814e335f2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 06:04:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gia.edgington/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[Debugging JavaScript, part 1.]]></title>
            <link>https://medium.com/@gia.edgington/debugging-javascript-part-1-59f97febbda9?source=rss-bb1814e335f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/59f97febbda9</guid>
            <dc:creator><![CDATA[Gia Edgington]]></dc:creator>
            <pubDate>Sat, 29 Feb 2020 19:32:54 GMT</pubDate>
            <atom:updated>2020-02-29T19:32:54.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T08w9jVhJMnj0j5Y" /><figcaption>Photo by <a href="https://unsplash.com/@epan5?utm_source=medium&amp;utm_medium=referral">Krzysztof Niewolny</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>JavaScript is considered to be a loosely typed language, one where you don’t have to specify what type of information will be stored in a variable in advance.</p><p>Some languages require you to declare a variable’s type before even running a program. This will tell you right away when a type is used in an inconsistent way. JavaScript considers types only when actually running the program, and even there often tries to implicitly convert values to the type it expects.</p><p>Also, JavaScript’s concept of bindings and properties is vague enough that it will rarely catch typos.</p><p>Because of these reasons, it will allow for sometimes too many nonsensical code to run, making the language very prone to bugs and errors.</p><p><strong>Strict Mode</strong></p><p>JavaScript can be made a <em>little</em> stricter by enabling <em>strict mode</em>. This is done by putting the string “use strict” at the top of a file or a function body. Here’s an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*VEonnGeXoBuiZGFHrhaTpQ.png" /></figure><p>Normally, when you forget to declare a variable, JavaScript will quietly create a global binding and use that. In strict mode, an error is reported instead.</p><p><strong>Debugging</strong></p><p>Once we notice there is something wrong with our program because it misbehaves or produces errors, the next step is to figure out <em>what</em> the problem is.</p><p>Sometimes it is obvious. The error message will point at a specific line of the program, and if we look at the error description and that line of code, we can often see the problem.</p><p>But sometimes the line that triggered the problem is simply the first place where a flaky value produced elsewhere gets used in an invalid way.</p><p>All modern browsers have a built-in JavaScript debugger. With a debugger we can set breakpoints and examine variables while the code is executing.</p><p><strong>The console.log() method</strong></p><p>We can use console.log() to display JavaScript values in the debugging window:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*2Biho0nYAB2k1sk3YHa3FA.png" /></figure><p>Putting a few strategic console.log calls into the program is a good way to get additional information about what the program is doing.</p><p><strong>Setting Breakpoints</strong></p><p>Browser come with the ability to set a breakpoint on a specific line on your code. When the execution of the program reaches a line with a breakpoint, this one is paused, and we will be able to inspect JavaScript values.After examining values, we can resume the execution of code .</p><p><strong>The <em>debugger</em> Keyword</strong></p><p>Another way to set a breakpoint is to include the debugger keyword, which will also pause the execution of JavaScript, and calls (if available) the debugging function.</p><p>If no debugging is available, the debugger statement has no effect.</p><p>With the debugger turned on, this code will stop executing before it executes the third line.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59f97febbda9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modular JavaScript]]></title>
            <link>https://medium.com/@gia.edgington/modular-javascript-ff500a04b32c?source=rss-bb1814e335f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff500a04b32c</guid>
            <dc:creator><![CDATA[Gia Edgington]]></dc:creator>
            <pubDate>Sun, 23 Feb 2020 21:02:15 GMT</pubDate>
            <atom:updated>2020-02-23T21:02:15.585Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fu7hkSSZvuDrDxpS" /><figcaption>Photo by <a href="https://unsplash.com/@lunarts?utm_source=medium&amp;utm_medium=referral">Volodymyr Hryshchenko</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote><em>From Wikipedia: </em>In software engineering, the module pattern is a design pattern used to implement the concept of software modules, defined by modular programming, in a programming language with incomplete direct support for the concept.</blockquote><p>The Module Pattern is one of the most common design patterns used in JavaScript.</p><p>A module is a piece of program that specifies which other pieces it relies on and which functionality it provides for other modules to use. It is created as an IIFE (Immediately-Invoked Function Expression).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*p9ixSI4-YzCGEtMMNueN6g.png" /></figure><p>Module interfaces make part of the module available to the outside world and keep the rest private.</p><p><strong>Anonymous Closures</strong></p><p>This is the fundamental construct that makes modules possible. All of the code that runs inside the function lives in a <strong>closure</strong>, which provides <strong>privacy</strong> throughout the lifetime of our application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*oziSPNZ8AEtay7_M-BYKyA.png" /></figure><p>In this example both var sum and function privateMethod are private properties of myModule. When we are accessing a module, we are accessing whatever it returns.</p><p><strong>Exporting Modules</strong></p><p>To get access to module features, we need to export them. This is done using the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export">export</a> statement.</p><p>We can either place it in front of any items we want exported out of the module or we can use the module.exports object to expose it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*ORJiMSBheFIqnb-tpu_Rxw.png" /></figure><p><strong>Dependencies</strong></p><p>The relations between modules are called <em>dependencies</em>. When a module needs a piece from another module, it is said to depend on that module. When this fact is clearly specified in the module itself, it can be used to figure out which other modules need to be present to be able to use a given module and to automatically load dependencies. To get access to modules needed we only have to import them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*Buc_hRjW_F400M41-DwOJA.png" /></figure><p><strong>Why use modules?</strong></p><p>Modules provide structure to bigger programs by separating the code into pieces with clear interfaces and dependencies. Also have maintainability, because they are self-contained and reusability.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff500a04b32c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Events]]></title>
            <link>https://medium.com/@gia.edgington/javascript-events-a64dd429f4e6?source=rss-bb1814e335f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a64dd429f4e6</guid>
            <dc:creator><![CDATA[Gia Edgington]]></dc:creator>
            <pubDate>Sun, 16 Feb 2020 16:40:09 GMT</pubDate>
            <atom:updated>2020-02-16T16:40:09.685Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q6i3oPYSF8G8QwzY" /><figcaption>Photo by <a href="https://unsplash.com/@solomac?utm_source=medium&amp;utm_medium=referral">Adam Solomon</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>JavaScript’s interaction with HTML is handled through events that occur when the user or the browser manipulates a page. Events are actions that happen in the system and to which programers can respond in some way.</p><p>Events are a part of the Document Object Model (DOM), they are fired inside the browser window, and tend to be attached to a specific item that resides in it — a single element, set of elements, the HTML document loaded in the current tab, or the entire browser window.</p><p>Browsers do this by allowing us to register functions as <em>handlers</em> for specific events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*Rdjz9MZCKv-Wov9wFNh2mg.png" /></figure><p>In this example, the <em>window</em> binding refers to a built-in object provided by the browser. It represents the browser window that contains the document. Calling its <em>addEventListener</em> method registers the second argument to be called whenever the event described by its first argument occurs.</p><h3>Events and DOM nodes</h3><p>Each browser event handler is registered in a context. We can attach a handler through the attribute whose name is the event name with <em>on</em> in front of it.</p><p>But a node can have only one <em>onclick</em> attribute, so we can register only one handler per node that way. The <em>addEventListener</em> method allows us to add any number of handlers so that it is safe to add handlers even if there is already another handler on the element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*q_Y0r83IG6uLU33RXmlvRw.png" /></figure><h3>Event Objects</h3><p>Sometimes inside an event handler function there will be a parameter specified with a name such as <em>event</em>, or <em>e</em>. This is called the <strong>event object</strong>, and it is automatically passed to event handlers to provide extra features and information.</p><h3>Propagation</h3><p>For most event types, handlers registered on nodes with children will also receive events that happen in the children. If a button inside a paragraph is clicked, event handlers on the paragraph will also see the click event.</p><p>But if both the paragraph and the button have a handler, the more specific handler — the one on the button — gets to go first. The event is said to <em>propagate</em> outward, from the node where it happened to that node’s parent node and on to the root of the document. Finally, after all handlers registered on a specific node have had their turn, handlers registered on the whole window get a chance to respond to the event.</p><p>At any point, an event handler can call the <em>stopPropagation </em>method on the event object to prevent handlers further up from receiving the event. This can be useful when, for example, we have a button inside another clickable element and we don’t want clicks on the button to activate the outer element’s click behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*GtQqFHjhVMIZ0YAGY1BEug.png" /></figure><p>This example registers <em>“mousedown”</em> handlers on both a button and the paragraph around it. When clicked with the right mouse button, the handler for the button calls <em>stopPropagation</em>, which will prevent the handler on the paragraph from running. When the button is clicked with another mouse button, both handlers will run.</p><p>We can also use the <em>target </em>property that refers to the node where they originated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a64dd429f4e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Higher-Order Functions]]></title>
            <link>https://medium.com/@gia.edgington/higher-order-functions-80378a5547b?source=rss-bb1814e335f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/80378a5547b</guid>
            <dc:creator><![CDATA[Gia Edgington]]></dc:creator>
            <pubDate>Sun, 09 Feb 2020 23:24:33 GMT</pubDate>
            <atom:updated>2020-02-09T23:24:33.021Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0wab1JZC1oppyMQE" /><figcaption>Photo by <a href="https://unsplash.com/@sapegin?utm_source=medium&amp;utm_medium=referral">Artem Sapegin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Higher-Order Functions are functions that operate on other functions, either by taking them as arguments or by returning them; they allow us to abstract over <em>actions</em>, not just values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*NioUBb1laKkcPvEojTYN4g.png" /></figure><h4><strong>Examples of Higher-Order Functions</strong></h4><p>Some of JavaScript most used methods are Higher-Order Functions:</p><p>The built-in array method, <em>forEach</em> provides something like a for/of loop as a higher-order function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*qTUQ9z47laB_Y7RzStSBqw.png" /></figure><p><strong>.filter()</strong></p><p>In this example, the function filters out the elements in an array that don’t pass a test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*cWKyUcJ0KDhILE8eR4q91A.png" /></figure><p>The function uses the argument named test, a function value, to fill a “gap” in the computation — the process of deciding which elements to collect.</p><p>Also, rather than deleting elements from the existing array, the filter method creates a new array with only the elements that pass the test. This function is <em>pure</em>. It does not modify the array it is given.</p><p>Like forEach, filter is a standard array method.</p><p><strong>.map()</strong></p><p>The map method transforms an array by applying a function to all of its elements and building a new array from the returned values. The new array will have the same length as the input array, but its content will have been <em>mapped</em> to a new form by the function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*z4fiM1ooBAlqoUNh5ltZhQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80378a5547b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Context API]]></title>
            <link>https://medium.com/@gia.edgington/react-context-api-b8b2ad81966b?source=rss-bb1814e335f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8b2ad81966b</guid>
            <dc:creator><![CDATA[Gia Edgington]]></dc:creator>
            <pubDate>Sun, 02 Feb 2020 20:56:40 GMT</pubDate>
            <atom:updated>2020-02-02T20:56:40.923Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2bqodL2saUZc7e8b" /><figcaption>Photo by <a href="https://unsplash.com/@ilyapavlov?utm_source=medium&amp;utm_medium=referral">Ilya Pavlov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I finally got to work with the React Context API.</p><p>Long story short, the Context API makes data available to specific components without having to pass props down at every level.</p><p>With Context, every component in the component tree has access to the data we put in our context.</p><p>If the child that utilizes the prop and the state where it resides is separated, by say, 2–3 intermediate components that do not directly utilize the prop, the Context API is perfect for the scenario.</p><p>First, once we have initialized our React project, we create a file context file in the /src folder.</p><h4>Creating the Context API</h4><p><em>To create a context, we use React.createContext which creates a context object. We can pass in anything as an argument to React.createContext.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*GqV7CS4yBshDM2ZRaSdr0w.png" /></figure><p>To make this context available to all our React components, we have to use a Provider.</p><p><strong><em>What is a Provider?</em></strong></p><p>Every context object comes with a Provider React component that allows consuming components to subscribe to context changes. It is the provider that allows the context to be consumed by other components.</p><p>In order to create our provider, we have to import our ThemeContext.</p><p>Once the ThemeContext has been imported, we have to enclose the contents of our App component in ThemeContext.Provider tags and give the ThemeContext.Provider component a props called value which will contain the data we want to make available to our component tree.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*4zPMp6kP0cOlqXzqqebs9Q.png" /></figure><p>Now the value of “dark” is available to all our components.</p><h3>useContext</h3><p>With useContext we inform the component to subscribe to the context we pass in as an argument. We can then retrieve the value being sent through context as the return value of useContext.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8b2ad81966b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTP Protocol]]></title>
            <link>https://medium.com/@gia.edgington/http-protocol-50794c1b5d4d?source=rss-bb1814e335f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/50794c1b5d4d</guid>
            <dc:creator><![CDATA[Gia Edgington]]></dc:creator>
            <pubDate>Fri, 24 Jan 2020 02:17:09 GMT</pubDate>
            <atom:updated>2020-01-24T02:17:09.855Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U3fwKtLNH9HWmOXh" /><figcaption>Photo by <a href="https://unsplash.com/@seven11nash?utm_source=medium&amp;utm_medium=referral">Marc Mueller</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A <em>network protocol</em> describes a style of communication over a network. In addition to protocols that dictate how information is communicated from machine to machine and application to application (IP and TCP respectively), it is frequently the case that the application itself has a system of rules for how to interpret the data that was sent.</p><p>The <em>Hypertext Transfer Protocol</em> (HTTP) is a protocol that dictates the format by which clients request web pages from a server and the format via which servers return information to clients. It comprises the system or rules of engagements for working with a web page.</p><p>Every time we use a service , this service is expecting the request to be received in a particular format.</p><p><strong>HTTP request line</strong></p><p>When we type <em>a website’s link</em> into your browser’s address bar, the browser first looks up the address of the server associated with <em>that website’s name</em> and tries to open a TCP connection to it on port 80, which is the default port for HTTP traffic. If the server exists and accepts the connection, the browser might send something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*fw3zLzxsywVssfSKxDc-qA.png" /><figcaption><strong>HTTP GET Request</strong></figcaption></figure><p>The information sent by the client is called the <em>request</em> and it starts with the <em>method, in this case GET</em>.</p><p>The part after the method name is the path of the <em>resource</em> the request applies to. A resource is just a file on the server.</p><p>After the resource path, the first line of the request mentions HTTP/1.1 to indicate the version of the HTTP protocol it is using.</p><p><strong>HTTP Request Methods</strong></p><p>The most common HTTP methods are:</p><p><strong>GET :</strong> requests the specified resource. Only retrieve data.</p><p><strong>POST :</strong> is used to send or submit information to the resource, often causing a change in state or side effects on the server.</p><p><strong>PUT :</strong> replaces the current representation of the target resource.</p><p><strong>DELETE :</strong> deletes a resource.</p><p>Based on whether the resource exists and whether the server is able to deliver the resource the client is requesting, a number of status codes can result.</p><p>The server’s response will start with a version as well, followed by the status of the response, first as a three-digit status code and then as a human-readable string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*JCn2xBC2xDW-RftJQ2p34A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*UaI0NxLhOqkZyoSNGyO77Q.png" /></figure><p>Status codes starting with a 2 indicate that the request succeeded. Codes starting with 4 mean there was something wrong with the request. 404 is probably the most famous HTTP status code — it means that the resource could not be found. Codes that start with 5 mean an error happened on the server.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50794c1b5d4d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Network Protocols — Part 1]]></title>
            <link>https://medium.com/@gia.edgington/network-protocols-part-1-3a0be316938?source=rss-bb1814e335f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a0be316938</guid>
            <dc:creator><![CDATA[Gia Edgington]]></dc:creator>
            <pubDate>Thu, 16 Jan 2020 04:34:24 GMT</pubDate>
            <atom:updated>2020-01-16T04:34:24.535Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Network Protocols — Part 1</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UKA0O0iWCSQdsBqm" /><figcaption>Photo by <a href="https://unsplash.com/@dulgier?utm_source=medium&amp;utm_medium=referral">Anastasia Dulgier</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The Internet is an interconnected network comprised of smaller networks that communicate with one another.</p><p>A <em>network protocol</em> describes a style of communication or set of rules over a network. There are protocols for sending email, for fetching email, for sharing files, and even for controlling computers that happen to be infected by malicious software.</p><p><strong>The Internet Protocol</strong></p><p>The Internet Protocol (IP) dictates how information is transmitted between point A and point B through the network. Its routing function enables internetworking, and essentially establishes the <strong>Internet</strong>.</p><p>Most protocols are built on top of other protocols. The Internet Protocol does not provide functionality for error recovering, lost data, or arrival to the remote host in another order than they are sent. The <em>Transmission Control Protocol</em> (TCP) is a protocol that addresses these problems, and that’s why the Internet Protocol suite is often referred to as TCP/IP. All Internet-connected devices “speak” it, and most communication on the Internet is built on top of it.</p><p><strong>Transmission Control Protocol</strong></p><p>The Transmission Control Protocol (TCP) complements the Internet protocol suite by directing the transmitted information to the correct program or service on the receiving machine.</p><p>A TCP connection works as follows: one computer is waiting or <em>listening</em>, for other computers to start talking to it. To be able to listen for different kinds of communication at the same time on a single machine, each listener has a number (called a <em>port</em>) associated with it. Most protocols specify which port should be used by default. With this number, coupled with an IP address, we can identify a specific program, particular service on a specific machine.</p><p>Some port numbers are commonly used and are standardized across all computers:</p><ul><li>FTP (file transfer) uses port 21.</li><li>SMTP ( e-mail) uses port 25.</li><li>DNS (Domain Name System) uses port 53.</li><li>HTTP (web browsing) uses port 80.</li><li>HTTPS (secure web browsing) uses post 443.</li></ul><p>Another computer can then establish a connection by connecting to the target machine using the correct port number. If the target machine can be reached and is listening on that port, the connection is successfully created. The listening computer is called the <em>server</em>, and the connecting computer is called the <em>client</em>.</p><p><strong>Guaranteed delivery.</strong></p><p>TCP will indicate how many packets the IP have split the data into and it orders the packets so they can be reconstructed on the receiving machine.</p><p><strong>Steps of the TCP/IP process:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*OM8BIOWNoSsfFKcCpPeDhw.png" /></figure><ul><li>When data is sent, TCP breaks it into smaller chunks and communicates those packets to the computer’s network software, adding a TCP layer onto the packet.</li><li>IP routes the individual packets from sender to receiver; this info is part of the IP layer surrounding the packet.</li><li>When the destination computer gets the packet, TCP looks at the header to see which program it belongs to; and since the route packets take may differ, TCP also must present those packets to the destination program in the proper order.</li></ul><p>If at any point along the way a router delivering information using the Internet Protocol dropped a packet, TCP would use additional information inside the headers to request that the sender pass along the extra packet so it could complete assembly.</p><p>After the packets have arrived, TCP ensures they are organized in the correct order and can then be reassembled into the intended unit of data and delivered to the correct service.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a0be316938" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Asynchronous JavaScript: Async/await]]></title>
            <link>https://medium.com/@gia.edgington/asynchronous-javascript-async-await-42b2edb4347a?source=rss-bb1814e335f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/42b2edb4347a</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Gia Edgington]]></dc:creator>
            <pubDate>Fri, 10 Jan 2020 03:24:55 GMT</pubDate>
            <atom:updated>2020-01-10T03:24:55.714Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aks-oOr7usjbkBJb" /><figcaption>Photo by <a href="https://unsplash.com/@lucabravo?utm_source=medium&amp;utm_medium=referral">Luca Bravo</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A thread is a single process that a program can use to complete tasks, where each of them will be run sequentially.</p><p>JavaScript is single-threaded so only one process can happen at a time. But using asynchronous JavaScript we can perform long network requests without blocking the main thread. Callbacks and promises have been used to solve this.</p><p>In this case, we’re going to cover async/await.</p><p><strong>Async/Await</strong></p><p>Async/await is a way to write asynchronous code on top of promises. Like promises, async-await is non-blocking. But the most important feature of async/await is its ‘like synchronous’ behavior.</p><p>Here is a code example implementing promises:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*k-DQdrkQplFAYJfihnEEWA.png" /></figure><p>Async/await code example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*Cw79qfYuFpjhilciCtvCuw.png" /></figure><p>The await keyword can only be used inside defined async functions. Async functions implicitly return a promise and the resolve value will be what it’s been returned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42b2edb4347a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a Promise?]]></title>
            <link>https://medium.com/@gia.edgington/what-is-a-promise-314d478b26d8?source=rss-bb1814e335f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/314d478b26d8</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Gia Edgington]]></dc:creator>
            <pubDate>Sun, 05 Jan 2020 00:18:26 GMT</pubDate>
            <atom:updated>2020-01-05T00:18:26.260Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UX2360DxcRikChpR" /><figcaption>Photo by <a href="https://unsplash.com/@nordwood?utm_source=medium&amp;utm_medium=referral">NordWood Themes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A <em>promise</em> is an asynchronous action that may complete at some point and produce a value.</p><p><strong>How Promises Work</strong></p><p>A promise can be returned synchronously from an asynchronous function.</p><p>Promises can either be in one of three states:</p><ul><li>resolved (the action finished successfully)</li><li>rejected (it failed).</li><li>pending: not yet fulfilled or rejected</li></ul><p>Resolve handlers (as registered with <em>then</em>) are called only when the action is successful, and rejections are automatically propagated to the new promise that is returned by <em>then</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*NnTMY6LDdPFKXGZD2418tQ.png" /></figure><p>The timeOut call will wait 2 seconds, and the log Hello!. The <em>.then()</em> method takes the resolved or rejected value.</p><p>Promises must follow a set of rules:</p><ul><li>It must supply a standard-compliant <em>.then()</em> method.</li><li>A pending promise may transition into a fulfilled or rejected state.</li><li>A fulfilled or rejected promise is settled, and must not transition into any other state.</li></ul><p>Once a promise is settled, it must have a value (which may be undefined). That value must not change.</p><p><strong>Promise Chaining</strong></p><p>Because <em>.then()</em> always returns a new promise, it’s possible to chain promises with precise control over how and where errors are handled. Promises allow you to simulate normal synchronous code’s try/catch behavior.</p><p>Like synchronous code, chaining will result in a sequence that runs in serial. In other words, you can do:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*7ioJoPGVZxQbYSZc7pfK-g.png" /></figure><p>Each of these functions will wait for the previous one to complete before starting. <em>handleErrors() </em>will run only in the case of promises rejection.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=314d478b26d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hash Tables]]></title>
            <link>https://medium.com/@gia.edgington/hash-tables-dbe4b5ce727c?source=rss-bb1814e335f2------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbe4b5ce727c</guid>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Gia Edgington]]></dc:creator>
            <pubDate>Sun, 29 Dec 2019 04:33:36 GMT</pubDate>
            <atom:updated>2019-12-29T04:33:36.210Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/419/0*1KLducVMlzPI7dwR.jpg" /></figure><p>Hash table is a data structure used to store keys/value pairs.</p><p>By using hash tables we can have access to an entry directly through its key value, rather than by having to determine its location first.</p><p>A hash table combines two things:</p><ul><li>A hash function, which returns a nonnegative integer value called hash code.</li><li>An array capable of storing data.</li></ul><p><strong>Hash function</strong></p><p>The hash function allows us to convert a key into an array index (an integer).</p><p>However, what is called a collision occurs when two pieces of data, when run through the hash function, yield the same hash code.</p><p>There are mainly two approaches to handle collision resolution:</p><p><strong>Hashing with linear probing:</strong></p><p>Implementing hashing is to store N key-value pairs in a hash table of size M &gt; N, relying on empty entries. Such methods are called <em>open-addressing</em> hashing methods. The simplest open-addressing method is called <em>linear probing</em>: when there is a collision (when we hash to a table index that is already occupied with a key different from the search key), then we just check the next entry in the table (by incrementing the index). There are three possible outcomes:</p><ul><li>key equal to search key: search hit</li><li>empty position (null key at indexed position): search miss</li><li>key not equal to search key: try next entry</li></ul><p>The recommended approach, however, is chaining.</p><p><strong>Hashing with separate chaining:</strong></p><p>A hash function converts keys into array indices. The second component of a hashing algorithm is collision resolution: a strategy for handling the case when two or more keys to be inserted hash to the same index. A straightforward approach to collision resolution is to build, for each of the M array indices, a linked list of the key-value pairs whose keys hash to that index. The basic idea is to choose M to be sufficiently large that the lists are sufficiently short to enable efficient search through a two-step process: hash to find the list that could contain the key, then sequentially search through that list for the key.</p><h4>Hash Table Strengths:</h4><ul><li><strong>Fast lookups</strong>. Lookups take O(1)<em>O</em>(1) time <em>on average</em>.</li><li><strong>Flexible keys</strong>. Most data types can be used for keys.</li></ul><h4>Weaknesses:</h4><ul><li><strong>Slow worst-case lookups</strong>. Lookups take O(n)<em>O</em>(<em>n</em>) time in the worst case.</li><li><strong>Unordered</strong>. Keys aren’t stored in a special order. If you’re looking for the smallest key, the largest key, or all the keys in a range, you’ll need to look through every key to find it.</li><li><strong>Single-directional lookups</strong>. While you can look up the <em>value</em> for a given key in O(1)<em>O</em>(1) time, looking up the <em>keys</em> for a given <em>value</em> requires looping through the whole dataset — O(n)<em>O</em>(<em>n</em>) time.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbe4b5ce727c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>