<?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: aprouja1</title>
    <description>The latest articles on DEV Community by aprouja1 (@aprouja1).</description>
    <link>https://dev.to/aprouja1</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%2F75986%2F58c415dd-cf1c-4152-8397-81904ca0b3ce.jpeg</url>
      <title>DEV Community: aprouja1</title>
      <link>https://dev.to/aprouja1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aprouja1"/>
    <language>en</language>
    <item>
      <title>An overlooked Array.every() gotcha</title>
      <dc:creator>aprouja1</dc:creator>
      <pubDate>Tue, 15 Oct 2019 21:44:40 +0000</pubDate>
      <link>https://dev.to/aprouja1/an-overlooked-array-every-gotcha-34ah</link>
      <guid>https://dev.to/aprouja1/an-overlooked-array-every-gotcha-34ah</guid>
      <description>&lt;p&gt;For those not familiar, the Array.every() method tests a condition against all items in an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fruits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Banana&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Plum&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Orange&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;//Is every fruit longer than 5 characters?&lt;/span&gt;
&lt;span class="nx"&gt;fruits&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;every&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fruit&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;fruit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//false&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Items are not just limited to simple strings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;people&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alex&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;37&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Carl&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Devon&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;77&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;

&lt;span class="c1"&gt;//Is every person at least 18 years old&lt;/span&gt;
&lt;span class="nx"&gt;people&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;every&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//true&lt;/span&gt;

&lt;span class="c1"&gt;//destructured&lt;/span&gt;
&lt;span class="nx"&gt;people&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;every&lt;/span&gt;&lt;span class="p"&gt;(({&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//true&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;But did you know what happens with an empty array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;toDoListItems&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="c1"&gt;//Are all of my items complete&lt;/span&gt;
&lt;span class="nx"&gt;toDoListItems&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;every&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;done&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;//true&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Well that was unexpected. Turns out that when &lt;code&gt;every&lt;/code&gt; is called on an empty array, the result is always true:  &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every"&gt;MDN - Array.every()&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Be careful not to use the Array.every() method when your Array may have a length of 0. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>Interactive JS Date Cheat Sheet</title>
      <dc:creator>aprouja1</dc:creator>
      <pubDate>Thu, 30 May 2019 22:36:42 +0000</pubDate>
      <link>https://dev.to/aprouja1/interactive-js-date-cheat-sheet-51np</link>
      <guid>https://dev.to/aprouja1/interactive-js-date-cheat-sheet-51np</guid>
      <description>&lt;p&gt;This is the story of my process building &lt;a href="https://jsdates.dev"&gt;JSDates.dev&lt;/a&gt;, my first published project and what I learned along the way.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why Dates?
&lt;/h1&gt;

&lt;p&gt;Remembering all of the various Javascript Date and Time methods has always been a struggle for me. Various methods have a partner with a slightly similar name, causing confusion:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;toISOString &amp;amp; toJSON&lt;/li&gt;
&lt;li&gt;toUTCString &amp;amp; toGMTString&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some have similar names but provide different results:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;getFullYear&lt;/li&gt;
&lt;li&gt;getUTCFullYear&lt;/li&gt;
&lt;li&gt;getYear&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some have different names and provide almost the exact same value:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;valueOf&lt;/li&gt;
&lt;li&gt;getTime&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Cheat Sheet
&lt;/h1&gt;

&lt;p&gt;With all of that in mind, I set out to create a tool that would allow me to input multiple dates, see all of the values of all of the methods and compare. Thus &lt;a href="https://jsdates.dev"&gt;JSDates.dev&lt;/a&gt; was born!&lt;/p&gt;

&lt;h1&gt;
  
  
  Tools &amp;amp; Methodology
&lt;/h1&gt;

&lt;p&gt;I've been a big proponent of Vue for some time now, so I knew that it would be my JS framework of choice. The CSS framework Bulma has some very helpful classes that allowed for quick styling. Although I am normally a VS Code user, i decided to try out CodeSandbox for this project. I hadn't used it for any previous projects, but its integration with Netlify was unbelievably easy to use in order to build on commit.&lt;/p&gt;

&lt;h1&gt;
  
  
  Learnings
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;CSS Grid is truly amazing, and is only going to get better. Setting up a responsive grid takes mere seconds.&lt;/li&gt;
&lt;li&gt;Vue's reactivity system continues to impress in terms of rendering speed&lt;/li&gt;
&lt;li&gt;Dates &amp;amp; Times are confusing, but understanding the options can be more valuable than adding a specific library&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Next Steps
&lt;/h1&gt;

&lt;p&gt;I tried quite hard to find a way to add function arguments without hard-coding the various options. Looping through prototype methods was fairly simple, but trying to determine what arguments went with those methods doesn't appear to be possible.&lt;/p&gt;

&lt;p&gt;Please feel free to give me your thoughts or open an issue on the &lt;a href="https://github.com/aprouja1/DateCheatSheet"&gt;Github Repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>vue</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
