<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tyler Caprioli</title>
    <description>The latest articles on DEV Community by Tyler Caprioli (@tcaprioli).</description>
    <link>https://dev.to/tcaprioli</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F463174%2F8e6b5f22-e1de-4d84-a8a0-d72b6be61fc5.png</url>
      <title>DEV Community: Tyler Caprioli</title>
      <link>https://dev.to/tcaprioli</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tcaprioli"/>
    <language>en</language>
    <item>
      <title>Arrays vs Linked Lists</title>
      <dc:creator>Tyler Caprioli</dc:creator>
      <pubDate>Fri, 18 Sep 2020 00:07:53 +0000</pubDate>
      <link>https://dev.to/tcaprioli/arrays-vs-linked-lists-2b2k</link>
      <guid>https://dev.to/tcaprioli/arrays-vs-linked-lists-2b2k</guid>
      <description>&lt;p&gt;Data structures are a core concept in computer science, and knowing how to identify and utilize each system correctly is the difference between an engineer and a developer. Today I'll be comparing arrays and linked lists, two prevalent data structures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Similarities
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;orders items sequentially&lt;/li&gt;
&lt;li&gt;flexible size (if array is dynamic)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Differences
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;arrays store items next to each other in memory while linked lists items aren't&lt;/li&gt;
&lt;li&gt;static arrays aren't flexible in size like linked lists are&lt;/li&gt;
&lt;li&gt;arrays are better for looking up items then linked lists are&lt;/li&gt;
&lt;li&gt;It's easier to perform operations on the ends of linked lists than it is on arrays&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>JS Cheatsheet: Dom Manipulation &amp; Event Listeners</title>
      <dc:creator>Tyler Caprioli</dc:creator>
      <pubDate>Thu, 03 Sep 2020 23:53:20 +0000</pubDate>
      <link>https://dev.to/tcaprioli/js-cheatsheet-dom-manipulation-event-listeners-3nm2</link>
      <guid>https://dev.to/tcaprioli/js-cheatsheet-dom-manipulation-event-listeners-3nm2</guid>
      <description>&lt;h1&gt;
  
  
  Manipulating the DOM
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Need to know
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To find an element: .querySelector(), .getElementBy()&lt;/li&gt;
&lt;li&gt;To add an element: .createElement(), .appendChild(), insertBefore(), .innerHTML&lt;/li&gt;
&lt;li&gt;To remove an element: .remove(), .removeChild()&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to use
&lt;/h2&gt;

&lt;p&gt;First find an element on the page you’d like to manipulate. You can do this by looking at the source HTML file or by pressing cmd+shift+c to select an element on the page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foww7mn9ccx297qrhpb7y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foww7mn9ccx297qrhpb7y.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this case, we’ve chosen the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element with an id of “dog-image-container”. For us to select this we’d use querySelector and save it to a variable for later use.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dogContainer = document.querySelector('#dog-image-container');&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now we want to add an &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; element that says “Dog Pics”. Let us begin by creating it. &lt;code&gt;let h1 = document.createElement('h1');&lt;/code&gt; Now that we have the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; element stored in our “h1” variable let’s assign it some text. &lt;code&gt;h1.innerHTML = "Dog Pics";&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fco0ftp2em0gcdgtxheni.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fco0ftp2em0gcdgtxheni.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you look in the console to the right you’ll see that we’ve added text to our h1 variable! But wait, it’s not on our page yet. That’s because creating an element doesn’t include it to the DOM. To do this we have to append our h1 variable to Its parent, dogContainer. There are two ways to do this; the first would be to use the appendChild method: &lt;code&gt;dogContainer.appendChild(h1);&lt;/code&gt; By calling the method on the parent class(in this case dogContainer) you will be adding the child to the end of the parent. What if you wanted the element at the top of the container though? There’s a method for that. &lt;code&gt;insertBefore()&lt;/code&gt; takes two arguments, the first is what element you are inserting and the second is the position you are inserting that element before.&lt;br&gt;
&lt;code&gt;dogContainer.insertBefore(h1,dogContainer.firstChild);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffea02rrgq42r91j3weov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffea02rrgq42r91j3weov.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We did it! If we wanted to remove the text we’ve just created it would be as simple as calling the remove() method on the h1 variable we created: &lt;code&gt;h1.remove();&lt;/code&gt; This method is a shortcut as it allows us to remove the element without looking for the parent. &lt;code&gt;removeChild()&lt;/code&gt;, however, requires both the parent and the child to work: &lt;code&gt;dogContainer.removeChild(h1);&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Event Listeners
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Need to know:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;desiredElement.addEventListener("type of event", callBackFunction())&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Event listeners allow us to interact with the page. Check out the MDN documentation for a list of available events. For our purposes, we want to be able to &lt;strong&gt;click&lt;/strong&gt; our new “Dog Pics” text and have it turn red. Lucky for us our desired element is already defined with our h1 variable. In our callback function, we’re defining what happens when we perform the action. We need our text to turn red.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;h1.style.color = 'red';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This line of code is calling the style attribute on our h1 element and assigning it a new color, red. Now we have all of the pieces of our puzzle to write our event listener:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;desiredElement = h1&lt;/li&gt;
&lt;li&gt;“type of event” = “click”&lt;/li&gt;
&lt;li&gt;call back function = h1.style.color = ‘red’;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;h1.addEventListener("click",function(event){h1.style.color = 'red';})&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy9nap6ybck4l1ht1xg4a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy9nap6ybck4l1ht1xg4a.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
