<?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 Will Resen on Medium]]></title>
        <description><![CDATA[Stories by Will Resen on Medium]]></description>
        <link>https://medium.com/@willresen?source=rss-f9cf307b6c98------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*Ew0tmZ6pajkxHEBKKRMHMA.jpeg</url>
            <title>Stories by Will Resen on Medium</title>
            <link>https://medium.com/@willresen?source=rss-f9cf307b6c98------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 19:00:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@willresen/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[Introduction to Asynchronous Programming in JavaScript]]></title>
            <link>https://medium.com/@willresen/introduction-to-asynchronous-programming-in-javascript-f0235d620a1?source=rss-f9cf307b6c98------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0235d620a1</guid>
            <category><![CDATA[callback]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Will Resen]]></dc:creator>
            <pubDate>Fri, 02 Aug 2019 05:31:52 GMT</pubDate>
            <atom:updated>2019-08-02T05:31:52.492Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript is a <strong><em>single-threaded</em></strong> <strong><em>programming language</em></strong>. In other words, the JavaScript interpreter can only execute code <em>one line at a time</em>.</p><p>Consider the following:</p><pre>const longFunc = () =&gt; {<br>  let count = 0;<br>  while (count &lt; Infinity) {<br>    count++<br>  }<br>  console.log(3);<br>}</pre><pre>console.log(1);<br>console.log(2);<br>longFunc();<br>console.log(4);</pre><p>Due to this code’s <em>synchronicity</em>, ‘4’ will not be logged until after longFunc finishes executing. If longFunc never finishes, console.log(4) will never be reached!</p><p>This is called <strong>blocking </strong>— the execution of longFunc <em>blocks</em> the execution of further code until its completion.</p><p>You may already see an issue that will arise from this behavior — how can a user enjoy an application that does not allow multi-tasking?</p><p>Fortunately, there are several ways to utilize <strong>asynchronous </strong>code to skirt around the problems that stem from blocking.</p><p>Asynchronicity in JavaScript does not mean <em>native </em>multi-threaded processing, but rather the utilization of the <strong>event loop</strong>, <strong>callback queue, </strong>and <strong>external APIs </strong>to let a longer-running function process<em> outside of the normal flow of the code.</em></p><p>Let’s refactor longFunc to utilize setTimeout, an asynchronous function that you may already be familiar with.</p><pre>const longFunc = () =&gt; {<br>  let count = 0;<br>  while (count &lt; Infinity) {<br>    count++<br>  }<br>  console.log(3);<br>}</pre><pre>console.log(1);<br>console.log(2);<br>setTimeout(longFunc, 0);<br>console.log(4);<br>console.log(5);</pre><pre>// 1<br>// 2<br>// 4<br>// 5<br>// ........</pre><p>Although this program will still hang once longFunc has been invoked, it successfully demonstrates how asynchronous code may operate.</p><p>So what’s going on here?</p><p>The invocation of setTimeout pushes a reference to longFunc into the <strong>callback queue</strong>. Also known as the <em>message queue </em>or the <em>event queue</em>, the callback queue<strong> </strong>contains pending code that will run only once the <strong>call stack</strong> is empty.</p><p>Once each function in the call stack has returned, the<em> </em><strong><em>event loop</em></strong> will determine whether the specified time has passed — if so, it will then pop longFunc out of the queue and invoke it.</p><p>Here’s the catch: setTimeout is not native to JavaScript. Since JavaScript is synchronous, <em>all</em> asynchronous functionality must come from an external API — in the case of setTimeout, the generalized Web API provided by web browsers.</p><p>With this in mind, it becomes easier to understand how functions like Node’s <strong>fs</strong> work: when making calls to <em>fs.readFile()</em> or <em>fs.writeFile()</em>, the operation is passed off to the innards* of Node to do work while the rest of the page’s code operates.</p><p>*I’m unfamiliar with the actual process — please drop a comment if you know.</p><p>If this makes sense, you’re ready to move on to the <strong>error-first</strong> <strong>callback pattern </strong>and the wonders of <strong>Promises</strong>.</p><p>If not, drop a comment and I will give you a hand.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0235d620a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Big O Notation (in JavaScript)]]></title>
            <link>https://medium.com/@willresen/introduction-to-big-o-notation-in-javascript-4353a9d93a64?source=rss-f9cf307b6c98------2</link>
            <guid isPermaLink="false">https://medium.com/p/4353a9d93a64</guid>
            <category><![CDATA[big-o-notation]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Will Resen]]></dc:creator>
            <pubDate>Sun, 26 May 2019 21:46:59 GMT</pubDate>
            <atom:updated>2019-05-27T03:34:24.986Z</atom:updated>
            <content:encoded><![CDATA[<p>If two identically-written functions are passed two different arrays, one containing one element and the other containing three thousand elements, which function will take longer to run? By how much?</p><p>Consider the following:</p><pre>let array1 = [1];<br>let array2 = [1, 2, &lt;--digits here--&gt;, 3000];</pre><pre>function alertFirstElement(array){<br>  alert(array[0]);<br>}</pre><pre>alertFirstElement(array1);<br>alertFirstElement(array2);</pre><p>How might we classify the amount of time needed for the above function to finish running? Will differently sized inputs have different runtimes? What if we substitute the above function for this one?</p><pre>function alertAllElements(array){<br>  array.forEach(element =&gt; alert(element));<br>};</pre><p>Regardless of how many elements are contained in the first function’s input, it will always operate <em>once. </em>The number of times the second function operates, however, is directly correlated to the size of the input it recieves. The runtime of these two functions may be compared by representing them in <em>Big O Notation </em>as <strong><em>O(1)</em></strong> and <strong><em>O(n)</em></strong>.</p><p>In short, <strong><em>Big O Notation is used to classify algorithms by how quickly their run-times grow in relation to their input.</em></strong></p><p>Big O Notation does not calculate the exact runtime of an algorithm (for example, “this function will finish running in 400ms”), but rather the <em>rate</em> at which its runtime grows when the size of its input increases.</p><p>Let’s dive a little deeper and take a look at some algorithms in <em>constant time, linear time, quadratic time, </em>and <em>logarithmic time.</em></p><h3>O(1): “C<em>onstant Time”</em></h3><p>Let’s consider the example provided at the beginning of this article:</p><pre>let array1 = [1];<br>let array2 = [1, 2, &lt;--digits here--&gt;, 3000];</pre><pre>function alertFirstElement(array){<br>  alert(array[0]);<br>}</pre><pre>alertFirstElement(array1);<br>alertFirstElement(array2);</pre><p>This function is in <em>constant time</em>, which is notated as <strong><em>O(1)</em></strong>, or “order one”. In other words, the time that this function takes to run will always be a constant amount regardless of the size of its input.</p><h3>O(n): “Linear Time”</h3><p>A function will be classified as “<em>order n</em>”, or<strong><em> O(n)</em></strong>, if its runtime grows at a 1:1 ratio to its input. Consider a function that loops through an array to find the first index of a specified value:</p><pre>function indexOf(array, target){<br>  for(let i = 0; i &lt; array.length; i++){<br>    if(array[i] === target){<br>      return i;<br>    }<br>  }<br>  return -1;<br>};</pre><pre>let array = [&quot;all&quot;, &quot;cows&quot;, &quot;eat&quot;, &quot;grass&quot;];<br>indexOf(array, &quot;cows&quot;); //will return 1</pre><p>Since Big O notation operates on <em>worst-case scenarios</em>, it is assumed that the target is located at the final index of the input array. Therefore, for an array with a length of 4, the function must iterate through all 4 elements to find its target.</p><h3><em>O(n²): “Quadratic Time”</em></h3><p>A function in quadratic time, or <strong><em>O(n²)</em></strong>, runs <em>n </em>number of times for each of the <em>n </em>items in its input.</p><p>Consider a loop within a loop:</p><pre>function multiplicationTable(array){<br>  let table = [];<br>  for(let x = 0; x &lt; array.length; x++){<br>    let row = [];<br>    for(let y = 0; y &lt; array.length; y++){<br>      row.push(array[x] * array[y]);<br>    }<br>    table.push(row);<br>  }<br>  return table;<br>}</pre><pre>console.log(multiplicationTable([1, 2, 3]));</pre><h3>O(log n): “Logarithmic Time”</h3><p>The most successful sort and search algorithms for large collections of data run in logarithmic time, or <strong><em>O(log n)</em></strong>. These algorithms, such as Quick Sort or binary searches, operate by cutting a collection in half and then recursively calling itself on each half. In a worst-case scenario, this operation iterates through the array <em>log n</em> times.</p><p>Although the mathematics of these operations are outside the scope of this article, I will soon be posting an in-depth explanation of the mechanics behind logarithmic sort and search algorithms.</p><p>Before wrapping up, I would like to make a final point: <em>Big O notation does not use constants</em>. As the size of an input approaches infinity, multiplying it by <em>n </em>has a diminishing effect. Therefore, <strong><em>O(2n)</em></strong> is simplified to <strong><em>O(n)</em></strong> as the constant becomes more and more irrelevant as the input grows.</p><p>That’s all for today, folks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4353a9d93a64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to JavaScript Data Structures]]></title>
            <link>https://medium.com/@willresen/introduction-to-javascript-data-structures-842fa870ebc1?source=rss-f9cf307b6c98------2</link>
            <guid isPermaLink="false">https://medium.com/p/842fa870ebc1</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[linked-lists]]></category>
            <dc:creator><![CDATA[Will Resen]]></dc:creator>
            <pubDate>Thu, 23 May 2019 19:24:53 GMT</pubDate>
            <atom:updated>2019-05-24T04:25:45.027Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to Data Structures in JavaScript</h3><p>In every programming language, data must be organized and stored in a way that allows it to be efficiently accessed. In JavaScript, this data may be categorized as one of seven primitive values (<em>numbers</em>, <em>strings</em>, <em>booleans</em>, <em>symbols</em>, <em>bigints</em>, <em>undefined </em>and <em>null) </em>or as an <em>object</em>. <strong>Data structures</strong> are collections that store data (values), the relationships between them (key-value pairs) and the operations that may be performed on them (methods). This article will discuss the most commonly used data structures in JavaScript — let’s begin!</p><p>In their simplest form, data structures are objects that contain mappings between keys and values. Arguably, the most basic data structure in JavaScript is the <em>array</em>:</p><pre>let array = [1, 2, 3, 4];</pre><p>An array is an <em>object</em> that is given special treatment by the language — its keys are the indices at which the elements exist, and its values are the elements themselves:</p><pre>let array = [1, 2, 3, 4];<br>console.log(Object.keys(array)); //will log [ &#39;0&#39;, &#39;1&#39;, &#39;2&#39;, &#39;3&#39; ]<br>console.log(Object.values(array)); //will log [ 1, 2, 3, 4 ]</pre><p>Arrays may be abstracted to two higher-level data structures called the <em>stack </em>and the <em>queue.</em></p><h3>Stacks</h3><p>A<strong> </strong><em>stack </em>is a simple data structure that can be visualized as (but not to be confused with) an array. A stack has two primary operations, <em>push </em>and <em>pop. Push </em>adds a new element to the stack, while <em>pop </em>removes the most recently added element. This process is called Last In, First Out (LIFO). Stacks may also be treated in reverse using <em>shift </em>and <em>unshift</em>.</p><p>It’s important to note that data structures are abstractions — although an array can serve as a stack, stacks may also be built using other data structures such as <em>linked lists</em> (which will be discussed later in this article).</p><h3>Queues</h3><p>Similar to a stack, a <em>queue </em>may also be visualized as an array. It has two operations, <em>unshift </em>and <em>pop</em>. Unshift <em>enqueues </em>(adds) a new item to the end of the queue while pop <em>dequeues </em>(removes) the oldest item from the beginning of the queue. Queues follow the First In, First Out (FIFO) protocol. Queues are best used when objects are needed to be managed in order — for example, when users are waiting in line to print a document or to login to a server.</p><h3>Linked Lists</h3><p>In JavaScript, <em>linked lists</em> may be thought of as embedded objects that store data in sequential order. Each entry is called a <em>node — </em>the first node is called the <em>head</em> and the last node is called the <em>tail</em>. Each node contains two properties, one for the data itself and the other a <em>pointer</em> to the <em>next</em> node in the list. The last node contains a pointer to <em>null</em>.</p><pre>let head = {<br>  val: &quot;node 1&quot;,<br>  next: {<br>    val: &quot;node 2&quot;,<br>    next: {<br>      val: &quot;node 3&quot;,<br>      next: null&quot; <br>    }<br>  }<br>};</pre><p>Note how there is no easy way to tell the length of a linked list, nor are there indices to keep track of a node’s position.</p><p>To find a specific node, the entire list must be traversed until the desired data is found.</p><p>Linked lists are superior to arrays when managing large quantities of data — when an element is removed or added to an array, every subsequent element will need to be reindexed.</p><p>In a linked list, however, only the preceding node’s pointer will change. In a <em>singly-linked list</em>, each node only contains a pointer to the <em>next</em> node. In a <em>doubly-linked list</em>, each node contains an additional pointer to the <em>previous</em> node. As you may have guessed, the head’s <em>previous</em> pointer points to <em>null</em>.</p><p>Like arrays, linked lists may function as <em>stacks </em>when the head is the only point for the addition and removal of nodes. Similarly, a doubly-linked list can function as a <em>queue</em> when nodes are allowed to be added only at the head of the list and removed at the tail (or vice versa).</p><h3>Trees</h3><p><em>Trees</em> are similar to linked lists due to their makeup of <em>nodes</em>. While linked lists are linear and can only move in two directions, trees are hierarchical and may branch into other <em>subtrees</em>. A <em>parent </em>node may have several different <em>child</em> nodes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OOO4w1e3RHhYr61HHXM8Sg.png" /></figure><p>In the example above, the <em>root </em>node has a value of 2 and its <em>child </em>nodes have the values of 7 and 5. 7 is the <em>parent </em>node for the values of 2 and 6, while the <em>child </em>node of 5 has a value of 9.</p><p>Trees may be traversed via their depth in the vertical direction (Depth First Traversal, or DFT) or via their breadth in the horizontal direction (Breadth First Traversal, or BFT). The <strong>Document Object Model</strong> (DOM) is an example of a tree that you may already be familiar with — the <em>html </em>parent node contains the child nodes of <em>head </em>and <em>body </em>which branch into the other familiar HTML tags like <em>&lt;p&gt;, &lt;div&gt;, </em>and &lt;<em>button&gt;</em>.</p><p>A derivation of trees, the <strong>graph </strong>data structure allows child nodes to have more than one parent nodes. <em>Edges </em>are the links that connect the nodes to one another — an example of a graph data structure are <em>Mixins </em>that contain many-to-many relationships.</p><h3>Hash Tables</h3><p>Last but not least, a <em>hash table</em> is a data structure that stores key-value pairs at numerical indices called <em>hashes</em>. The indices are generated by running each key through a <em>hash function </em>that converts the key to an index based on the function’s implementation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hHhihbhvkjBmHD4WbAHTA.png" /></figure><p><em>Hashes</em> are the generated indexes, and <em>buckets</em> (or <em>slots</em>) are arrays that contain the values (values may share hashes).</p><p>A hash table that utilizes buckets may be thought of as a combination of an array and a linked list — each element in the hash table (which is similar to an array) is a header for a linked list, and all of the elements that hash into the same location are added to the list.</p><p>When a bucket is full, any additional element will be stored in the <em>overflow </em>bucket that is shared by all buckets in the table. However, an efficient implementation will distribute elements evenly among buckets, and thus use of the <em>overflow </em>bucket should be kept at a minimal level.</p><p>Hash tables are incredibly efficient at storing data that needs to be quickly accessed. They are best used when retrieving a specific object from a collection of similar objects such as ISBNs, Social Security Numbers and user IDs.</p><p>Although there are multiple variations to these data structures, the aforementioned few are the first that you should familiarize yourself with.</p><p>Stay tuned for an in-depth revisit for each of these structures!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=842fa870ebc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Object-Oriented Programming in JavaScript]]></title>
            <link>https://medium.com/@willresen/introduction-to-object-oriented-programming-in-javascript-598070bb2546?source=rss-f9cf307b6c98------2</link>
            <guid isPermaLink="false">https://medium.com/p/598070bb2546</guid>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[instantiation-patterns]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[programming-paradigms]]></category>
            <dc:creator><![CDATA[Will Resen]]></dc:creator>
            <pubDate>Fri, 17 May 2019 05:16:17 GMT</pubDate>
            <atom:updated>2019-05-18T06:13:01.711Z</atom:updated>
            <content:encoded><![CDATA[<p>Object-Oriented Programming is a fundamental paradigm of the JavaScript language that offers simplicity when working with a wide range of data structures. <em>OOP</em> provides an efficient means for keeping track of data by allowing programmers to create independent modules that contain their own properties and methods. Prototypal inheritance allows these methods and properties to be shared between similar objects. This article will discuss the strengths and weaknesses of the various ways to create objects in JavaScript — let’s begin!</p><p>An <em>object literal </em>is the simplest form of an object:</p><pre>var object = {};</pre><p>Within it we may add properties that consist of key-value pairs:</p><pre>var object = {<br>  &#39;key1&#39;: &#39;value1&#39;,<br>  &#39;key2&#39;: &#39;value2&#39;<br>};</pre><p>Although keys will always be coerced as strings, values have no such restriction:</p><pre>var object = {<br>  &#39;key1&#39;: function(parameter){ console.log(&quot;Hello World!&quot;) },<br>  &#39;key2&#39;: {&#39;key&#39;: &#39;value&#39;};<br>};</pre><p>Object literals are a fast and easy way to quickly store data, but what if we want multiple objects that have similar features?</p><p>Typing everything manually would be quite tiresome:</p><pre>var guitar1 = {<br>  &#39;manufacturer&#39;: &#39;Gibson&#39;,<br>  &#39;model&#39;: &#39;ES-335&#39;,<br>  &#39;year&#39;: 1958<br>};</pre><pre>var guitar2 = {<br>  &#39;manufacturer&#39;: &#39;Fender&#39;,<br>  &#39;model&#39;: &#39;American Deluxe Telecaster&#39;,<br>  &#39;year&#39;: 2019<br>};</pre><pre>var guitar3 = {<br>  &#39;manufacturer&#39;: &#39;Martin&#39;,<br>  &#39;model&#39;: &#39;HD-28V&#39;,<br>  &#39;year&#39;: 2016<br>};</pre><pre>//repeat ad infinitum...</pre><p>Fortunately, to reduce our workload, JavaScript gives us the ability to utilize <em>classes. </em>Classes are<strong><em> any construct capable of producing similar objects that conform to the same interface.</em></strong> In other words, classes provide an easy way to create objects that share properties and methods. These objects, called <em>instances</em> of a class, are created by a <em>constructor</em> <em>function</em>. Creating an instance of a class by calling a constructor function is called <em>instantiating, </em>and JavaScript has four primary instantiation patterns:</p><ol><li>Functional Instantiation</li><li>Functional-Shared Instantiation</li><li>Prototypal Instantiation</li><li>Pseudoclassical Instantiation</li></ol><p>Let’s discuss each of these patterns and their relative strengths and weaknesses.</p><p><em>Functional instantiation </em>consists of a function that creates an object, adds properties and methods, and then returns the object.</p><pre>function Guitar(manufacturer, model, year){<br>  var object = {};<br>  object.manufacturer = manufacturer;<br>  object.model = model;<br>  object.year = year;<br>  object.play = function(){ console.log(&quot;Let&#39;s rock!&quot;) };<br>  return object;<br>};</pre><pre>var myGuitar = Guitar(&quot;Gibson&quot;, &quot;ES-335&quot;, 1958);<br>console.log(myGuitar.model); //will return &quot;ES-335&quot; </pre><p>Note how the first letter of the function’s name is capitalized — this signals that we are creating a class.</p><p>Every time the above function is called, the data contained within it is duplicated. Thus, the new objects have methods that point to different functions regardless of if they are identically written. Although the previous example involves an object with only simple properties and a single method, objects in larger applications will likely use more memory. To save space, an alteration must be made to prevent the unnecessary duplication of methods.</p><p><em>Functional-shared instantiation</em> alters functional instantiation to avoid duplicating methods upon each new object’s creation. It utilizes a property attached to the constructor function that contains the shared methods as well as an <em>extend </em>function that copies the methods to the new object.</p><pre>function Guitar(manufacturer, model, year){<br>  var object = {};<br>  object.manufacturer = manufacturer;<br>  object.model = model;<br>  object.year = year;<br>  extend(object, Guitar.methods);<br>  return object;<br>};</pre><pre>function extend(object, methods){<br>  for(let key in methods){<br>    object[key] = methods[key];<br>  }<br>};</pre><pre>Guitar.methods = {<br>  &#39;play&#39;: function(){ console.log(&quot;Let&#39;s rock!&quot;) },<br>  &#39;shred&#39;: function(){ console.log(&quot;Diddly Diddly!&quot;) },<br>  &#39;hendrix&#39;: function(){ console.log(&quot;Wah Wah!&quot;) }<br>}</pre><pre>var myGuitar = Guitar(&quot;Gibson&quot;, &quot;ES-335&quot;, 1958);<br>myGuitar.shred(); //will log &quot;Diddly Diddly!&quot;</pre><p>The next two instantiation patterns utilize the <em>prototype chain </em>that allows an object to inherit<em> </em>properties from another. All objects in JavaScript eventually delegate failed property lookups to the <em>Object prototype, </em>a property of the Object constructor that contains the shared properties of all objects in the language. This delegation of failed property lookups is called <em>inheritance.</em></p><pre>myGuitar.toString(); //will return [object Object]</pre><p>Even though <em>toString</em> was not defined as a property in Guitar.methods, it still runs without error. When a property does not exist on an instance of the constructor function, the lookup then ‘falls through’ to the prototype object to check if the property exists there. If it does, our new object then <em>inherits</em> the property.</p><p><em>Prototypal instantiation </em>uses <em>Object.create() </em>to instantiate a new object that passes failed lookups up the prototype chain to a specified parent object.</p><pre>var instrument = {<br>  &#39;play&#39;: () =&gt; console.log(&quot;Let&#39;s rock!&quot;),<br>  &#39;practice&#39;: () =&gt; console.log(&quot;Getting better...&quot;),<br>  &#39;record&#39;: () =&gt; console.log(&quot;Testing... 1, 2, 3.&quot;)<br>}</pre><pre>function Guitar(manufacturer, model, year){<br>  var object = Object.create(instrument);<br>  object.manufacturer = manufacturer;<br>  object.model = model;<br>  object.year = year;<br>  return object;<br>};</pre><pre>var myGuitar = Guitar(&quot;Fender&quot;, &quot;Stratocaster&quot;, 2019);<br>myGuitar.practice(); //will log &quot;Getting better...&quot;</pre><p>Although prototypal instantiation is a step closer to finding an ideal instantiation pattern, there is still one more to cover.</p><p><em>Pseudoclassical instantiation </em>is intended to reduce the amount of typing used in prototypal instantiation. It uses the <em>new </em>and <em>this</em> keywords to respectively create and add properties to an object. Methods are added directly to the constructor function by means of the <em>prototype </em>object,<em> </em>a property which is automatically created for every function.</p><pre>function Guitar(manufacturer, model, year){<br>  this.manufacturer = manufacturer;<br>  this.model = model;<br>  this.year = year;<br>}</pre><pre>Guitar.prototype.play = () =&gt; console.log(&quot;Let&#39;s rock!&quot;);<br>Guitar.prototype.practice = () =&gt; console.log(&quot;Getting better...&quot;);<br>Guitar.prototype.record = () =&gt; console.log(&quot;Testing... 1, 2, 3.&quot;);</pre><pre>var myGuitar = new Guitar(&quot;Gibson&quot;, &quot;ES-335&quot;, 1958);<br>myGuitar.play(); //will log &quot;Let&#39;s rock!&quot;</pre><p>As a reminder, new properties may also be added directly to an instance without affecting other objects of the same class:</p><pre>myGuitar.previousOwner = &quot;Eric Johnson&quot;;<br>console.log(myGuitar.previousOwner); //will log &quot;Eric Johnson&quot;</pre><pre>var newGuitar = new Guitar(&quot;Fender&quot;, &quot;Telecaster&quot;, 2019);<br>console.log(newGuitar.previousOwner); //will log undefined</pre><p>With these methods of instantiation, you’re ready to conquer the world of object-oriented programming!</p><p>For extra practice, try creating an inventory for a local store. What kind of products do they have? Which properties will their respective objects share, and which ones will differ?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=598070bb2546" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>