<?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: Laurie</title>
    <description>The latest articles on DEV Community by Laurie (@laurieontech).</description>
    <link>https://dev.to/laurieontech</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%2F67245%2Fe491c3cb-9cae-4f54-9a6e-79cbd28eea4f.jpeg</url>
      <title>DEV Community: Laurie</title>
      <link>https://dev.to/laurieontech</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/laurieontech"/>
    <language>en</language>
    <item>
      <title>Functions, fat arrows and parentheses</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Tue, 07 Sep 2021 15:25:03 +0000</pubDate>
      <link>https://dev.to/laurieontech/functions-fat-arrows-and-parentheses-585o</link>
      <guid>https://dev.to/laurieontech/functions-fat-arrows-and-parentheses-585o</guid>
      <description>&lt;p&gt;If you develop with JavaScript you likely use functions fairly often. And, because you're a developer, you've likely made some mistakes.&lt;/p&gt;

&lt;p&gt;For me, it was last week. I called a function without parentheses and it didn't exactly do what I wanted. But why? Why was that a mistake? In React there are lots of times we use functions without parentheses and everything works just fine!&lt;/p&gt;

&lt;p&gt;Today we're going to talk about why.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do parantheses impact functions
&lt;/h2&gt;

&lt;p&gt;Let's start with a typical function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;someString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;some string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we wanted to call this function, we'd do so like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;someString&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="c1"&gt;// result is now "some string"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But what happens if we do this?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;someString&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;result&lt;/code&gt; is now equal to &lt;code&gt;[Function: someString]&lt;/code&gt;. It's a reference to the function rather than the result of evaluating the function.&lt;/p&gt;

&lt;p&gt;Well that was a quick post. Always use parentheses, problem solved.&lt;/p&gt;

&lt;p&gt;Not so fast!&lt;/p&gt;

&lt;h2&gt;
  
  
  React and functions
&lt;/h2&gt;

&lt;p&gt;Sometimes in React we want to execute a function. But other times, we want to pass around a reference.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ExampleComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;clickHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I was clicked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;clickHandler&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;onClick&lt;/code&gt; is an &lt;a href="https://laurieontech.com/posts/event-listeners/#what-about-react"&gt;event handler&lt;/a&gt; which takes a function as a callback. So it needs a reference to the function it's going to call.&lt;/p&gt;

&lt;p&gt;What happens if we add parantheses? Will it still work?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ExampleComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;clickHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I was clicked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;clickHandler&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nope! Nothing will get logged. The event handler was expecting a function that it can call. However, it got the return value of the function.&lt;/p&gt;

&lt;p&gt;Any other syntax weirdness we should talk about? Sure, why not!&lt;/p&gt;

&lt;h2&gt;
  
  
  Parameters
&lt;/h2&gt;

&lt;p&gt;By default, &lt;code&gt;event&lt;/code&gt; is passed as an argument to the callback function. Something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ExampleComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;clickHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I was clicked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;clickHandler&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This actually introduces an interesting detail! The code above is equivalent to the code below, passing our function wrapped in an anonymous function that exposes &lt;code&gt;event&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ExampleComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;clickHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I was clicked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;clickHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Anonymous functions
&lt;/h2&gt;

&lt;p&gt;As it turns out, we can define our function inline.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ExampleComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I was clicked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This also gives us the opportunity to pass our own parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ExampleComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;clickHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&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;clickHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I was clicked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But what if we want the event object in addition to our other parameter(s)?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ExampleComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;clickHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;clickHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I was clicked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Click me&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes sense if we think about what we already know. That &lt;code&gt;event&lt;/code&gt; is always passed, whether we reference it or not.&lt;/p&gt;

&lt;h2&gt;
  
  
  I'm a little confused
&lt;/h2&gt;

&lt;p&gt;If that last example confused you, that's ok! It looks a lot like our earlier example where we passed the result of a function rather than a reference to it.&lt;/p&gt;

&lt;p&gt;The trick is to look at the definition of &lt;code&gt;clickHandler&lt;/code&gt; a little bit closer. We'll make it a bit more verbose to make that easier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;clickHandler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "result" of clickHandler is a function! It returns a reference to a function. So we're all good.&lt;/p&gt;

&lt;h2&gt;
  
  
  Functions are fun
&lt;/h2&gt;

&lt;p&gt;I know that was a lot of syntax, but I hope you feel a bit more confident. Knowing what is happening under the hood can turn guess and check errors into intentional fixes. You'll still make mistakes, we all do, but maybe you'll catch them faster.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Interviews are about telling a story</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Tue, 24 Aug 2021 12:34:23 +0000</pubDate>
      <link>https://dev.to/laurieontech/interviews-are-about-telling-a-story-21no</link>
      <guid>https://dev.to/laurieontech/interviews-are-about-telling-a-story-21no</guid>
      <description>&lt;p&gt;Last week I was in &lt;a href="https://twitter.com/DThompsonDev"&gt;Danny Thompson's&lt;/a&gt; twitter space talking about tech interviews. One piece of advice I gave was about preparing for conversational interviews and the types of questions you get asked.&lt;/p&gt;

&lt;p&gt;Apparently, people wanted to learn more!  And as always, I'm happy to oblige.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tech Interviews aren't only about code
&lt;/h2&gt;

&lt;p&gt;You may be familiar with guides for studying and preparing to ace tech interviews. Oftentimes they focus on algorithms and data structures. You'll also find write-ups and websites on studying for systems design interviews and other abstract exercises. Prepping for these types of questions are great. However, they aren't the only type of interview rounds you're likely to encounter.&lt;/p&gt;

&lt;p&gt;In most interview processes you'll have rounds that are very conversational in nature. They're typically a mix of technical and people skills questions. This post is about setting yourself up for success in these interviews.&lt;/p&gt;

&lt;h2&gt;
  
  
  What type of questions can you expect?
&lt;/h2&gt;

&lt;p&gt;The interviewer in conversational rounds can be anyone from a manager to a colleague to a skip level director. However, their goal is often the same. How do you collaborate? How do you communicate? What level of experience do you have handling challenges that are both technical and people-focused?&lt;/p&gt;

&lt;p&gt;Examples of the types of questions they might ask are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tell me about a time where you had to say no to a request?&lt;/li&gt;
&lt;li&gt;Have you ever had to give feedback to a more senior engineer? Can you tell me about that?&lt;/li&gt;
&lt;li&gt;What mistakes have you made in implementing a system? What would you do differently next time?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are hundreds of these types of questions, but you get the idea.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does a good answer look like?
&lt;/h2&gt;

&lt;p&gt;Sometimes these answers explicitly ask for a story, e.g. "tell me about a time". Sometimes it's less overt and they say "how would you handle". In either case, having a real life example you can point to helps ground your answer and show the experience you have.&lt;/p&gt;

&lt;p&gt;Stories should have a beginning, a middle and an end. They should show a positive outcome or an outcome where you can point to the mistakes that were made and what you'd do differently. They also need to be clear, concise and effective. Most importantly, the story needs to clearly connect to the question being asked.&lt;/p&gt;

&lt;p&gt;This sounds like a lot to ask on the spot! You have to think about the question, come up with an anecdote, package it well, and relay it back to the interviewer. All in 5 or so minutes, maybe less. Yikes!&lt;/p&gt;

&lt;h2&gt;
  
  
  How?!
&lt;/h2&gt;

&lt;p&gt;This is where my original advice comes into play. You don't need to think of every question you might be asked. But you should think of some stories ahead of time.&lt;/p&gt;

&lt;p&gt;Have 3-5 stories in your back pocket going into an interview. They should highlight different aspects of your collaboration and communication style so that they can fit the questions being asked.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A story where you did everything right&lt;/li&gt;
&lt;li&gt;A story where you did something wrong and learned from it&lt;/li&gt;
&lt;li&gt;A story involving a peer&lt;/li&gt;
&lt;li&gt;A story involving management&lt;/li&gt;
&lt;li&gt;A story involving another team, company, or external player&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This list isn't exhaustive, but it will help you start thinking about some good anecdotes. Once you've zeroed in on your stories you can start to practice talking about them.&lt;/p&gt;

&lt;p&gt;When prepping a story consider an interview enviroment. You want to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Get to the point quickly - remove any extraneous or overly detailed pieces of information&lt;/li&gt;
&lt;li&gt;Be clear - beginning, middle and end, make sure that your point comes across&lt;/li&gt;
&lt;li&gt;Connect to the question - this takes some practice, but try and mention the keywords of the question as you're concluding the story and drive home how it connects&lt;/li&gt;
&lt;li&gt;Show off - this doesn't mean you should brag, but try and show yourself in a positive light, even when the story involves a misadventure&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thinking through all of this ahead of time will give you confidence going into these types of interviews. You won't be stuck trying to think of a good anecdote in live time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Important caveats
&lt;/h2&gt;

&lt;p&gt;There are a couple mistakes to avoid.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If they ask for a time you weren't successful, don't use a story where you were. Always have a story for when you messed up. Be able to analyze what you could have done differently, but don't avoid the point of the question.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You don't need to be an engineer to answer these questions well. If you are a career changer you can tell a story involving retail managers, your fellow line cook, the military. Whatever it is, this is a great opportunity to show how your current experience relates to the role and why you have more to offer than someone straight out of school.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Interviews are about you
&lt;/h2&gt;

&lt;p&gt;For all the flaws with technical interviews, conversational interviews are different. You don't need to be the most outgoing person in the room or have studied a textbook worth of potential questions. A few focused areas of prep will help you show off your skills and experience.&lt;/p&gt;

</description>
      <category>career</category>
      <category>interview</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Introducing `findLast` and `findLastIndex`</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Wed, 16 Jun 2021 15:02:15 +0000</pubDate>
      <link>https://dev.to/laurieontech/introducing-findlast-and-findlastindex-1fan</link>
      <guid>https://dev.to/laurieontech/introducing-findlast-and-findlastindex-1fan</guid>
      <description>&lt;p&gt;I'm back with another introduction to JavaScript syntax! Currently in Stage 2, we're going to talk about &lt;code&gt;findLast&lt;/code&gt; and &lt;code&gt;findLastIndex&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Array.prototype.find
&lt;/h2&gt;

&lt;p&gt;Let's start by talking about a sometimes used array function called &lt;code&gt;find&lt;/code&gt;. It's a nice utility method that helps you find the first element in an array that meets the given criteria.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;d&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;letter&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// { letter: 'c', integer: 2 },&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a complimentary function called &lt;code&gt;findIndex&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;d&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;letter&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can imagine why someone might want to do this. If you're looking for an element that matches what you want, but you only need one, this is super useful and very performant.&lt;/p&gt;

&lt;h2&gt;
  
  
  But it's only first
&lt;/h2&gt;

&lt;p&gt;While &lt;code&gt;find&lt;/code&gt; is great, it always gets the first element that meets the criteria. What happens if you're continuously pushing elements onto your array and you want the "most recent" element that meets the criteria. This would be the element closest to the end.&lt;/p&gt;

&lt;p&gt;You could do this in a few ways. The one that comes to mind for me is to reverse the array and then use &lt;code&gt;find&lt;/code&gt;. But this isn't performant for large arrays, it requires more steps than it should, and it doesn't work well if there aren't any matching elements in the array.&lt;/p&gt;

&lt;p&gt;Enter &lt;code&gt;findLast&lt;/code&gt;. It's the mirror function to &lt;code&gt;find&lt;/code&gt;, but it works from the end of the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;d&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findLast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;letter&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// { key: 'c', integer: 3 }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is also a matching &lt;code&gt;findLastIndex&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;letter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;d&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;integer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;findLastIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;letter&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that if it can't find an element that matches the criteria, it will return &lt;code&gt;-1&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What do you think?
&lt;/h2&gt;

&lt;p&gt;In my mind we can never have too many array utility methods! Whether I need them or not. But how about you?&lt;/p&gt;

&lt;p&gt;If you're interested in learning more, check out the &lt;a href="https://github.com/tc39/proposal-array-find-from-last"&gt;proposal&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>`at` coming soon to ECMAScript</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Mon, 14 Jun 2021 14:41:59 +0000</pubDate>
      <link>https://dev.to/laurieontech/at-coming-soon-to-ecmascript-1k91</link>
      <guid>https://dev.to/laurieontech/at-coming-soon-to-ecmascript-1k91</guid>
      <description>&lt;p&gt;If you're a JavaScript developer you've likely used arrays quite a bit. They're an essential data structure within the language.&lt;/p&gt;

&lt;p&gt;In fact, they're so essential that the array prototype has seen rapid expansion in the past few years, with things like &lt;code&gt;flat&lt;/code&gt; and &lt;code&gt;filter&lt;/code&gt; added. And we're not done yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accessor
&lt;/h2&gt;

&lt;p&gt;In order to access an element in an array, you need to know its index. Indeces in JavaScript are zero-based, so the first element is at index 0.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;arr&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;a&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;b&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;c&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;d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// this is "a"&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// this is "c"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see in the example above, you can access the first element, or the third element. What about the last element? In other languages you might be able to do something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;arr&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;a&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;b&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;c&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;d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// This is NOT "d"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But not in JavaScript! Why not? Well, as it turns out, &lt;code&gt;-1&lt;/code&gt; is already a valid key. Arrays are really objects with indeces as keys. So &lt;code&gt;arr[-1]&lt;/code&gt; is looking at the &lt;code&gt;arr&lt;/code&gt; object and the value of the &lt;code&gt;"-1"&lt;/code&gt; key, which is &lt;code&gt;undefined&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The last element
&lt;/h2&gt;

&lt;p&gt;Then how do we access the last element without knowing its index? There are ways to do it, but its certainly more verbose. You can use the length lookup.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;arr&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;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// this is "d"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or you have the slice option.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;// this is "d"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Introducing at
&lt;/h2&gt;

&lt;p&gt;That's why the &lt;code&gt;at&lt;/code&gt; function is under consideration. Instead of those options, you'd be able to write this instead.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;at&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// this is "d"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that this works for all valid negative indices, up until you pass the first element.&lt;/p&gt;

&lt;p&gt;The great thing about &lt;code&gt;at&lt;/code&gt; is that it can replace square brackets all together.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;at&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// this is still "a"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And what about an invalid index?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;at&lt;/span&gt;&lt;span class="p"&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;// this is undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Seems pretty all encompassing.&lt;/p&gt;

&lt;h2&gt;
  
  
  An aside on history
&lt;/h2&gt;

&lt;p&gt;As it turns out, this was attempted before using &lt;code&gt;item&lt;/code&gt;. However, it wasn't web compatible as it clashed with major libraries. So, &lt;code&gt;at&lt;/code&gt; is the current proposal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Would you use it?
&lt;/h2&gt;

&lt;p&gt;Hopefully this will move forward to Stage 4 soon and be officially adopted. I can see this being nice syntactic sugar for accessing array elements.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Give Better Code Reviews</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Thu, 10 Jun 2021 03:23:34 +0000</pubDate>
      <link>https://dev.to/laurieontech/how-to-give-better-code-reviews-3jik</link>
      <guid>https://dev.to/laurieontech/how-to-give-better-code-reviews-3jik</guid>
      <description>&lt;p&gt;If you're working on a codebase with more than one contributor you likely participate in code review. Also known as the act of signing off on someone else's code before it can be merged into the main branch.&lt;/p&gt;

&lt;p&gt;The idea behind code review is incredibly sound. We all benefit from an extra pair of eyes. It helps team members gain context on other pieces of the code base. It ideally keeps the patterns and choices consistent, helping people onboard down the line.&lt;/p&gt;

&lt;p&gt;Yet the words "code review" can often strike fear into the minds of those who hear it. Those who have endured bad code reviews often describe the experience as demoralizing or condescending. We don't want to make people feel that way, so let's talk about what it takes to be a good reviewer.&lt;/p&gt;

&lt;h2&gt;
  
  
  What not to do
&lt;/h2&gt;

&lt;p&gt;Let's start by explaining what code review is not.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Code review is &lt;strong&gt;not&lt;/strong&gt; being a human linter&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If a given piece of syntax should never show up in your codebase, add an automatic linter rule. It's a waste of time to make this a manual process and it doesn't provide a ton of value. If it's not worth it to add the rule then it's probably not worth it to point out in the code review either. If you do, you're being pedantic.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Code review is &lt;strong&gt;not&lt;/strong&gt; about proving how smart you are&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The goal of code review is entirely about the person who wrote the code growing their skills, and your codebase getting more robust. None of that is about your ego or showing off how much you know.&lt;/p&gt;

&lt;h2&gt;
  
  
  So how do I do it right?
&lt;/h2&gt;

&lt;p&gt;Now that we have that out of the way, we can talk about what you &lt;em&gt;should&lt;/em&gt; do.&lt;/p&gt;

&lt;h3&gt;
  
  
  This is a two way conversation
&lt;/h3&gt;

&lt;p&gt;Yes, there are power dynamics at play in code review. The reviewer may have a more senior title or have more experience in the codebase at hand. The original author may take that into account when weighing the recommendations, but as a reviewer you need to recognize that what you say isn't gospel. You may be missing context, or misunderstand what the original author is trying to do.&lt;/p&gt;

&lt;p&gt;Given that, it's better to ask questions when phrasing recommendations. Instead of "You should do it Y way", try "Can you talk about your reasons for choosing X? In most cases I'd use Y, is there a reason not to here?". Typically, this has the same outcome but it feels more collaborative and leaves open an opportunity for all participants to learn.&lt;/p&gt;

&lt;h3&gt;
  
  
  This isn't just about what is wrong
&lt;/h3&gt;

&lt;p&gt;Code reviews are asynchronous, but they don't have to read that way. The goal is to provide feedback and not all feedback is negative. It's just as valid to say "Cool! I didn't know you could do that". And you should. It will balance out the overall tenor of the review and leave the author with a sense of where they can improve as well as where they should double down.&lt;/p&gt;

&lt;h3&gt;
  
  
  Not everything is blocking
&lt;/h3&gt;

&lt;p&gt;This may seem contrary to my comment above about being a human linter. However, not all things can be linted. Naming is a great example of this. Sometimes, you may have a recommendation that should not prevent the code from moving forward, but you want to note anyway.&lt;/p&gt;

&lt;p&gt;Marking these things as "NB" or non-blocking can be a great way to provide a quick note that an author can consider but doesn't have to listen to. This is especially helpful if you have an idea for an improvement but don't feel strongly about it. Or you have a question but don't want the back and forth to hold up getting the feature in.&lt;/p&gt;

&lt;h2&gt;
  
  
  What am I looking for?
&lt;/h2&gt;

&lt;p&gt;Now that we've talked about how to give feedback, let's talk about what to give feedback on. If code review isn't for pointing out syntax improvements, what is it for?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Integration points&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Is there a spot that may cause friction with another system? Do you need to loop someone else into the review? Does there need to be a synchronous conversation? Point that out.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Error boundaries&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Is there an edge case that isn't considered or handled? Talk about it. Make sure to address it before the code gets merged.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Unecessary bloat&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Does the code propose including a new library or system of some kind? Does it need to? It's worth discussing.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pattern deviation&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Are you deviating from the way you've handled this type of functionality or data elsewhere in the codebase? Why? Let's talk about it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Scalablility&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Is the way the is code written going to cause problems down the road? Bring it up early even if you choose to go for the short term solution.&lt;/p&gt;

&lt;p&gt;This is not an exhaustive list, but it should give you an idea of areas of concern that reviews can help aleviate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Level up your team
&lt;/h2&gt;

&lt;p&gt;The goal of a code review is to help level up the team and improve the long term health of the codebase. So focus on learning opportunities for your colleagues and yourself. And keep practicing--code review is a skill.&lt;/p&gt;

</description>
      <category>career</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>React 18: Terms and Functionality</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Thu, 10 Jun 2021 03:21:14 +0000</pubDate>
      <link>https://dev.to/laurieontech/react-18-terms-and-functionality-165l</link>
      <guid>https://dev.to/laurieontech/react-18-terms-and-functionality-165l</guid>
      <description>&lt;p&gt;As of today, &lt;a href="https://reactjs.org/blog/2021/06/08/the-plan-for-react-18.html"&gt;React 18 Alpha&lt;/a&gt; is here! This is exciting news as the last major release, 17, didn't include new functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's new?
&lt;/h2&gt;

&lt;p&gt;If you're interested in learning about the new features, I'd encourage you to look at the &lt;a href="https://github.com/reactwg/react-18/discussions"&gt;GitHub discussions&lt;/a&gt;. The React team has done a great job of explaining things in detail and is actively answering questions.&lt;/p&gt;

&lt;p&gt;The big takeaway is that you can use React 18 without having to change your existing application code. If you want to use the new features, you'll opt in rather than being forced to rewrite large chunks of code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cool, is that it?
&lt;/h2&gt;

&lt;p&gt;If that's all you wanted to know and you're ready to dive into the links above, go right ahead! But since I'm me, I found myself wondering about all the terminology I've heard over the past year or so. What is the right way to talk about React 18 going forward?&lt;/p&gt;

&lt;h3&gt;
  
  
  Suspense
&lt;/h3&gt;

&lt;p&gt;This functionality was available starting with React 16.6. The idea was that you could designate a loading state while you waited for some code to load.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Suspense&lt;/span&gt; &lt;span class="na"&gt;fallback&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Spinner&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ProfilePage&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Suspense&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;React 18 does indeed dive into more in the world of Suspense. In fact, the way Suspense works has changed. You can read more in the &lt;a href="https://github.com/reactwg/react-18/discussions/7"&gt;GitHub discussion&lt;/a&gt; but it's helpful to point out the terminology changes. Specifically, the pre-React 18 Suspense implementation is now referred to as &lt;code&gt;Legacy Suspense&lt;/code&gt; and the new implementation is &lt;code&gt;Concurrent Suspense&lt;/code&gt;. Why? Let's talk concurrent React!&lt;/p&gt;

&lt;h3&gt;
  
  
  Concurrent
&lt;/h3&gt;

&lt;p&gt;This is the term you'll see most often in all of the various discussions/blog posts. So what exactly is concurrent React? "Concurrent" is the word being used to describe a suite of new features that rely on a specific type of internal implementation.&lt;/p&gt;

&lt;p&gt;This includes things like &lt;code&gt;startTransition&lt;/code&gt; that helps you account for expensive state transitions. It also covers &lt;code&gt;SuspenseList&lt;/code&gt;, a way to coordinate the various &lt;code&gt;Suspense&lt;/code&gt; fallback states. There are a couple other headline features, but the big takeaway is that concurrent React is a way of getting, and keeping, your pages interactive--even if they're actively doing other things.&lt;/p&gt;

&lt;p&gt;It's important to note that these are not the only concurrent features that will eventually end up in React, but they're a big start on the journey.&lt;/p&gt;

&lt;h3&gt;
  
  
  Server Components
&lt;/h3&gt;

&lt;p&gt;In December of 2020, Dan Abramov and Lauren Tan gave a great talk introducing &lt;a href="https://reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html"&gt;server components&lt;/a&gt;. In this video they talked about writing React components server side and having the result of that component sent to the client and rendered.&lt;/p&gt;

&lt;p&gt;This was a very cool demo! ...and it's not a part of React 18. However, React 18 does set the stage for some of this functionality in the future.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Let's talk about Lodash</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Fri, 04 Jun 2021 18:03:21 +0000</pubDate>
      <link>https://dev.to/laurieontech/let-s-talk-about-lodash-39eo</link>
      <guid>https://dev.to/laurieontech/let-s-talk-about-lodash-39eo</guid>
      <description>&lt;p&gt;If you were a JavaScript developer during a certain era, you're likely familiar with the library &lt;a href="https://lodash.com/"&gt;Lodash&lt;/a&gt;. It's a utility library full of functions that make it easier to manipulate arrays, objects and strings. Lodash included so many critical functions that, for a long time, it was one of the first things developers would download when setting up a new project. However, times have changed.&lt;/p&gt;

&lt;p&gt;So let's talk about how we might think about Lodash in the context of today.&lt;/p&gt;

&lt;h2&gt;
  
  
  ECMAScript
&lt;/h2&gt;

&lt;p&gt;For a primer on ECMAScript and TC39 I recommend reading my post on the &lt;a href="https://dev.to/laurieontech/the-ecmascript-ecosystem-2e13"&gt;ECMAScript Ecosystem&lt;/a&gt;. With that out of the way, let's talk about new features to the language.&lt;/p&gt;

&lt;h3&gt;
  
  
  Arrays
&lt;/h3&gt;

&lt;p&gt;One of the things Lodash is known for are wonderful functions for handling arrays. For example, flattening them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]]]&lt;/span&gt;
&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flatten&lt;/span&gt;&lt;span class="p"&gt;.(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// [1,2,[3,4]]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We don't need to use Lodash for this anymore! &lt;code&gt;Array.prototype.flat&lt;/code&gt; is a thing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]]]&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// [1,2,[3,4]]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In fact, the &lt;code&gt;flat&lt;/code&gt; function handles all three of the Lodash flatten methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]]]&lt;/span&gt;

&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flatten&lt;/span&gt;&lt;span class="p"&gt;.(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// [1,2,[3,4]]&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// [1,2,[3,4]]&lt;/span&gt;

&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flattenDeep&lt;/span&gt;&lt;span class="p"&gt;.(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// [1,2,3,4]&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;Infinity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// [1,2,3,4]&lt;/span&gt;

&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flattenDepth&lt;/span&gt;&lt;span class="p"&gt;.(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// [1,2,3,4]&lt;/span&gt;
&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// [1,2,3,4]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Objects
&lt;/h3&gt;

&lt;p&gt;Another popular method that people reach for is Lodash's &lt;code&gt;get&lt;/code&gt;. This one found a JS substitute a bit more recently.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a.b.c&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method helps you dive deep into objects and not worry about whether or not the values exist. As an alternative, we now have &lt;a href="https://dev.to/laurieontech/optional-chaining-has-arrived-111l"&gt;optional chaining&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="c1"&gt;// 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As it turns out, &lt;code&gt;get&lt;/code&gt; takes a third parameter, a default value. To match this functionality we have &lt;a href="https://dev.to/laurieontech/nullish-coalescing-let-falsy-fool-you-no-more-41c0"&gt;nullish coalescing&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-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;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;a.b.e&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="s1"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// default&lt;/span&gt;

&lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="c1"&gt;// default&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Goodbye Lodash?
&lt;/h2&gt;

&lt;p&gt;You may think that these examples mean Lodash is no more! Well, not so fast.&lt;/p&gt;

&lt;p&gt;While ECMAScript has added a number of new features in the past few years, there are still parts of Lodash that don't have native replacements.&lt;/p&gt;

&lt;p&gt;Some are under discussion, like the &lt;a href="https://github.com/tc39/proposal-pipeline-operator"&gt;pipeline operator&lt;/a&gt;, which has some similarities to Lodash's &lt;a href="https://lodash.com/docs/4.17.15#chain"&gt;chain method&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Others are still just a twinkle in JavaScript's eye. &lt;code&gt;groupby&lt;/code&gt; and &lt;code&gt;deepmerge&lt;/code&gt; are commonly referenced in the category of things people would like native implementations of.&lt;/p&gt;

&lt;h2&gt;
  
  
  So why does it matter?
&lt;/h2&gt;

&lt;p&gt;You might wonder why this matters. If some things have native alternatives and others don't, why not use Lodash for everything and make your life easier?&lt;/p&gt;

&lt;p&gt;Well, Lodash isn't exactly small. Installing it as a dependency in your project doesn't matter so much, but loading it up for every page isn't ideal. So you want to consider a couple things.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If you don't have to use a Lodash dependency and can use a native solution, do so.&lt;/li&gt;
&lt;li&gt;If you've determined you need a Lodash method, don't import the entire library.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Instead of doing this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash/map&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, there is a &lt;a href="https://github.com/lodash/babel-plugin-lodash"&gt;Babel plugin&lt;/a&gt; that can do this for you. There is also a &lt;a href="https://www.npmjs.com/package/lodash-webpack-plugin"&gt;webpack plugin&lt;/a&gt; that will further optimize things.&lt;/p&gt;

&lt;h2&gt;
  
  
  And that's it
&lt;/h2&gt;

&lt;p&gt;Now go forth with your newfound Lodash knowledge! Make intentional choices about what needs a third-party dependency. And be sure to check out the &lt;a href="https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore"&gt;do you need Lodash&lt;/a&gt; project.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>productivity</category>
      <category>performance</category>
    </item>
    <item>
      <title>Diving into Husky and Lint-staged</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Wed, 12 May 2021 14:47:52 +0000</pubDate>
      <link>https://dev.to/laurieontech/diving-into-husky-and-lint-staged-2hni</link>
      <guid>https://dev.to/laurieontech/diving-into-husky-and-lint-staged-2hni</guid>
      <description>&lt;p&gt;Last week I talked about &lt;a href="https://laurieontech.com/posts/eslint/"&gt;ESLint&lt;/a&gt; and its usefulness for keeping projects consistent amongst multiple contributors. If you haven't read that post I recommend doing so before diving into this one.&lt;/p&gt;

&lt;p&gt;Today, we're going to focus on running ESLint automatically to ensure that the main branch of your project always follows your specific ruleset.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lint-staged
&lt;/h2&gt;

&lt;p&gt;The first tool to talk about is &lt;a href="https://www.npmjs.com/package/lint-staged"&gt;lint-staged&lt;/a&gt;. Lint-staged is configured in your package.json file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"lint-staged"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"*.js"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"eslint --fix"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As seen in the above example, you can use a glob pattern to tell lint-staged which files to run against. Additionally, you can give lint-staged a command to execute against those files. In many cases, you'll want more than one command, which lint-staged supports. In this case, you'll run ESLint and &lt;a href="https://prettier.io/"&gt;prettier&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"lint-staged"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"*.js"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"eslint"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"prettier --write"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So how does lint-staged work? It's specifically designed to work on "staged" files, thus the name. This means files you've changed or created but haven't yet committed to your project. Working on staged files limits the number of files you need to lint at any given time and makes the workflow faster. The commands you configure will run "pre-commit". As you're attempting to commit files to your project you'll see ESLint run in your terminal. Once it's done you may have successfully committed or find yourself with linting errors you need to fix before you're able to commit the code.&lt;/p&gt;

&lt;p&gt;However, what you may not realize, is that lint-staged is not the only tool working under the hood. Lint-staged is designed to work with another tool called &lt;a href="https://www.npmjs.com/package/husky"&gt;husky&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Husky
&lt;/h2&gt;

&lt;p&gt;You may have come across husky before without noticing. For many years it was configured via a few lines of code in your package.json file. Something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nl"&gt;"husky"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"pre-commit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"lint-staged"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, the latest version of husky, v6, has changed this approach. Now, husky uses distinct bash files with filenames that match the workflow step they correspond to, e.g. "pre-commit". Luckily you don't have to set this up yourself and husky has a nice CLI command to do it for you.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx husky-init &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm &lt;span class="nb"&gt;install
&lt;/span&gt;npx husky add .husky/pre-commit &lt;span class="s2"&gt;"npm test"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line of the command is a one-time initialization script that ensures all your coworkers will have husky installed on their machine before they try to commit files.&lt;/p&gt;

&lt;p&gt;The second line creates the &lt;code&gt;pre-commit&lt;/code&gt; file inside the &lt;code&gt;.husky&lt;/code&gt; directory. If you look at the file you'll notice it's running a &lt;code&gt;husky.sh&lt;/code&gt; script prior to whatever commands you initialized it with. This can technically be removed, but I'd recommend keeping it. The script allows for a few things, including the use of a &lt;code&gt;--no-verify&lt;/code&gt; flag that bypasses the checks.&lt;/p&gt;

&lt;p&gt;Once you've initialized the directory and associated file you can add whatever commands you want to it. In my case, I replaced &lt;code&gt;npm test&lt;/code&gt; with &lt;code&gt;npm lint-staged&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pre-push
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;pre-commit&lt;/code&gt; workflow is more or less the husky happy path. But what if your project doesn't want to lint on commit and would prefer to lint when a developer attempts to push their changes to a branch?&lt;/p&gt;

&lt;p&gt;While it's tempting to create a &lt;code&gt;.husky/pre-push&lt;/code&gt; file and run lint-staged, it won't work. The &lt;code&gt;pre-push&lt;/code&gt; husky workflow is correct, but running lint-staged at that point will turn up 0 matching files. This makes sense, though it certainly messed me up for a bit, because committed files are no longer staged. Instead, you have a couple of options.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run ESLint against all the files: &lt;code&gt;eslint '*.js'&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Diff against &lt;code&gt;main&lt;/code&gt;: &lt;code&gt;eslint --no-error-on-unmatched-pattern $(git diff main... --name-only --- '*.js')&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note that this is one example of a diff command and there are numerous considerations depending on your project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next steps and CI
&lt;/h2&gt;

&lt;p&gt;Running ESLint, or prettier, or even tests as part of your git workflow is important because it helps you fail fast. However, it's not a replacement for CI checks. Typically, you'll want to run these commands in both environments to ensure nothing slips through.&lt;/p&gt;

&lt;p&gt;But altogether these tools help ensure a cleaner, more consistent production codebase. Long term, that's a big win for any project.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Guide to ESLint</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Tue, 04 May 2021 13:41:23 +0000</pubDate>
      <link>https://dev.to/laurieontech/a-guide-to-eslint-4mj7</link>
      <guid>https://dev.to/laurieontech/a-guide-to-eslint-4mj7</guid>
      <description>&lt;p&gt;I spent the last week working on ESLint configuration and ensuring that syntax checks were built into the developer workflow. In the process, I read a bunch of different docs, which is usually my signal that an "all in one" blog post needs to be written! So here we go.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Eslint?
&lt;/h2&gt;

&lt;p&gt;For starters, ESLint is a tool that statically analyzes your code. Typically, it's used to ensure consistent syntax across a project with multiple collaborators. You've likely used ESLint without realizing it because it was already configured in your project. Ever seen those red squiggly lines in VS code? Those are often courtesy of Eslint.&lt;/p&gt;

&lt;p&gt;One thing to keep in mind is that ESLint is incredibly powerful. It has the ability to not only analyze code, but transform it. We'll get to that later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;ESLint allows you to set project-level rules using an &lt;code&gt;.eslintrc&lt;/code&gt; file. Since every team and project are slightly different, the control you have over your ruleset is quite extensive.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rules
&lt;/h3&gt;

&lt;p&gt;For every rule, let's say you're setting the &lt;code&gt;no-console&lt;/code&gt; rule, you can decide whether the rule should be &lt;code&gt;off&lt;/code&gt;, or set to &lt;code&gt;warn&lt;/code&gt; or &lt;code&gt;error&lt;/code&gt;. Like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;no-console&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="s1"&gt;warn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, the &lt;code&gt;no-console&lt;/code&gt; rule determines whether console log statements should exist in the codebase. If the rule is set to &lt;code&gt;off&lt;/code&gt; then console.log can be littered through your code and the linter won't care. If it's set to &lt;code&gt;warn&lt;/code&gt;, the linter will let you know the there are console.log statements in the code, but it won't be a showstopper. But if the rule is set to &lt;code&gt;error&lt;/code&gt;, linting will fail if a console.log statement shows up in the code.&lt;/p&gt;

&lt;p&gt;While this is helpful, some rules need to get more specific. For example, ESLint has a rule called &lt;code&gt;import/no-extraneous-dependencies&lt;/code&gt;. The goal of this rule is to catch situations in which you've imported a dependency into your file that is not included in your project's package.json.&lt;/p&gt;

&lt;p&gt;While you could use &lt;code&gt;off&lt;/code&gt;, &lt;code&gt;warn&lt;/code&gt;, or &lt;code&gt;error&lt;/code&gt;, it's not as helpful as it could be. That's because there are different types of dependencies, like &lt;a href="https://laurieontech.com/posts/package-json/#devdependencies"&gt;devDependencies and peerDependencies&lt;/a&gt;. A more nuanced configuration of the rule would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;import/no-extraneous-dependencies&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;devDependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;optionalDependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;peerDependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code will only show a linting error when core dependencies are imported but not included. Any other dependency type can be safely ignored.&lt;/p&gt;

&lt;h3&gt;
  
  
  Extends
&lt;/h3&gt;

&lt;p&gt;You may be thinking that this seems a bit tedious. Do you really want to go through and determine your preferences for all of these individual rules? You may, but probably not. In fact, in most cases, you'll only need to configure a handful of individual rules; the rules that differ from the ruleset you're extending.&lt;/p&gt;

&lt;p&gt;Many projects use the core ESLint rules, as shown here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;extends&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;eslint:recommended&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// highlight-line&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;no-console&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="s1"&gt;warn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, ESLint also allows you to extend rulesets that are exported by other projects. So you may opt to use the React recommendations, for example.&lt;/p&gt;

&lt;h3&gt;
  
  
  Root
&lt;/h3&gt;

&lt;p&gt;Another interesting thing about ESLint is that it follows a cascade model. Suppose you're using a monorepo structure with multiple packages that each have their own &lt;code&gt;.eslintrc&lt;/code&gt; file. You can include a configuration file in the root of your repo. In that case, ESLint will check the configuration file closest to a given line of code first and move up the tree, merging as it goes.&lt;/p&gt;

&lt;p&gt;Typically, the top-level directory will include &lt;code&gt;root: true&lt;/code&gt; so ESLint knows it can stop looking for additional config files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;root&lt;/span&gt;&lt;span class="p"&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;// highlight-line&lt;/span&gt;
  &lt;span class="na"&gt;extends&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;eslint:recommended&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;no-console&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="s1"&gt;warn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, this rule can exist in any &lt;code&gt;.eslintrc&lt;/code&gt;. So, if you wanted to include a standalone package in your monorepo that should not comply with the top-level &lt;code&gt;.eslintrc&lt;/code&gt;, you can do that. This is a great trick so that you don't need to supersede all of the rules at the top level.&lt;/p&gt;

&lt;h3&gt;
  
  
  Overrides
&lt;/h3&gt;

&lt;p&gt;Alternatively, you may want to supersede individual files that wouldn't have their own &lt;code&gt;.eslintrc&lt;/code&gt;. In that case, you can use &lt;code&gt;overrides&lt;/code&gt;, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;no-console&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="s1"&gt;warn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// highlight-start&lt;/span&gt;
  &lt;span class="na"&gt;overrides&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;files&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;example/*.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="na"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;no-console&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="s1"&gt;error&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="c1"&gt;// highlight-end&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CLI
&lt;/h2&gt;

&lt;p&gt;Now that you have ESLint configured, what can it actually do?&lt;/p&gt;

&lt;p&gt;If you run an ESLint command it will go through the files in your project and spit out all the warnings and errors to the command line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;eslint &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You may remember that I mentioned up top that ESLint can perform transforms. Running ESLint with the &lt;code&gt;--fix&lt;/code&gt; flag means it will attempt to change any syntax that errors out! It's worth noting that it can't fix every error it finds, but it can handle some of them.&lt;/p&gt;

&lt;p&gt;You can also use the &lt;code&gt;--debug&lt;/code&gt; flag which will show you what rules ESLint is using. This is helpful if you're attempting to determine why something is failing/passing that shouldn't be.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scripts
&lt;/h2&gt;

&lt;p&gt;While running ESLint locally is helpful, the point of ESLint is repeatability and consistency in your project. To get that you likely want to add ESLint commands to your package.json scripts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"eslint 'packages/**/*.{js,jsx,ts,tsx}'"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you do that you can make use of things like husky! We'll talk about that next time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wow
&lt;/h2&gt;

&lt;p&gt;There is a lot in this post but there is, even more, I didn't cover. In the scripts example, I used a glob, there are flags like &lt;code&gt;--quiet&lt;/code&gt;, you can even ignore certain files throughout your project. But this is a good start towards helping you understand the setup of an existing project or how to start setting up your own.&lt;/p&gt;

&lt;p&gt;And who knows, an ESLinterror may lead to finding and solving a bug! It did for me 😃.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>productivity</category>
      <category>beginners</category>
    </item>
    <item>
      <title>From JavaScript to Rust : Data Types</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Tue, 27 Apr 2021 13:44:08 +0000</pubDate>
      <link>https://dev.to/laurieontech/from-javascript-to-rust-data-types-13ff</link>
      <guid>https://dev.to/laurieontech/from-javascript-to-rust-data-types-13ff</guid>
      <description>&lt;p&gt;You may have been following my journey to learn Rust as I covered topics like &lt;a href="https://laurieontech.com/posts/rust-mut/"&gt;mutable variables&lt;/a&gt;, &lt;a href="https://laurieontech.com/posts/ownership/"&gt;ownership&lt;/a&gt; and &lt;a href="https://laurieontech.com/posts/rust-ref/"&gt;references&lt;/a&gt; and &lt;a href="https://laurieontech.com/posts/rust/"&gt;crates&lt;/a&gt;. These learnings fell into two distinct categories.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stuff that has a clear parallel in JavaScript land&lt;/li&gt;
&lt;li&gt;Stuff that's brand new, and I have no existing mental model for&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Yet, as I started to read and write more Rust code, I realized I was missing one big piece of the puzzle when it comes to learning a new language. I didn't have a strong understanding of data types in Rust. I quickly discovered that this information fell into a third "learning category". Stuff that overlaps with my JavaScript mental model in a way that's contradictory.&lt;/p&gt;

&lt;p&gt;Given that reality, I figured a post was in order! So without further ado, let's talk data types.&lt;/p&gt;

&lt;h2&gt;
  
  
  Primitives
&lt;/h2&gt;

&lt;p&gt;A JavaScript primitive is similar to what Rust calls a scalar type. Rust has four scalar types: booleans, integers, floating point numbers, and characters.&lt;/p&gt;

&lt;p&gt;Additionally, The Rust Reference mentions &lt;a href="https://doc.rust-lang.org/reference/types.html"&gt;primitive types&lt;/a&gt;, which includes &lt;code&gt;str&lt;/code&gt; and &lt;code&gt;Never&lt;/code&gt; on top of the four scalar types.&lt;/p&gt;

&lt;h3&gt;
  
  
  Boolean
&lt;/h3&gt;

&lt;p&gt;Let's start with something familiar, booleans. Booleans, or &lt;code&gt;bool&lt;/code&gt; in Rust, are a type with two possible values: &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;. This matches up with our JavaScript understanding, so no changes here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Number
&lt;/h3&gt;

&lt;p&gt;The same can't be said of numbers. In Rust, you need to care about what type of number you're storing. Is it an integer or a floating point number? What amount of space, in bits, does storing it take? Is it signed or unsigned?&lt;/p&gt;

&lt;p&gt;In Rust you can initialize integers of five different sizes, from 8-bit to 128-bit, either signed or unsigned. For floating point numbers you have either f32 or f64; the first is single precision and the second, double precision.&lt;/p&gt;

&lt;h3&gt;
  
  
  String
&lt;/h3&gt;

&lt;p&gt;You may have noticed that I didn't mention strings as Rust scalar types, I mentioned &lt;code&gt;char&lt;/code&gt;. This is accurate. However, Rust does have a primitive type &lt;code&gt;str&lt;/code&gt;. The strange thing is you likely won't use it other than as a reference to a specific string stored in memory, &lt;code&gt;&amp;amp;str&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you want to create or manipulate strings, you want the growable type &lt;code&gt;String&lt;/code&gt;. But be careful! The methods you're used to, like &lt;code&gt;len&lt;/code&gt; (aka length), won't return what you expect.&lt;/p&gt;

&lt;h2&gt;
  
  
  Structural types
&lt;/h2&gt;

&lt;p&gt;In JavaScript, most structural types are specific implementations of the JavaScript object type. But we'll break them out individually for the sake of this post.&lt;/p&gt;

&lt;h3&gt;
  
  
  Arrays
&lt;/h3&gt;

&lt;p&gt;Now we get to the part where you'll need to rewire your internal JavaScript dictionary. An &lt;code&gt;array&lt;/code&gt; is a valid Rust type. Unfortunately, that's not entirely helpful. An array in Rust is of fixed size. If you expect to create static data that won't change but you want to reference/look it up in an array structure then this may be what you want.&lt;/p&gt;

&lt;p&gt;More likely, though, you want a Vector. &lt;code&gt;vec&lt;/code&gt; is similar to &lt;code&gt;String&lt;/code&gt;. It's an array type that you can own and grow dynamically.&lt;/p&gt;

&lt;h3&gt;
  
  
  Objects
&lt;/h3&gt;

&lt;p&gt;Search "Rust object type" and you're bound to be confused. You'll end up reading up on Trait object types, which is a bit more advanced than what you're after. What you're really looking for is &lt;code&gt;struct&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In Rust, a struct is defined as a type composed of other types. Sounds like a JavaScript object to me! It's worth reading about &lt;a href="https://doc.rust-lang.org/std/keyword.struct.html"&gt;structs&lt;/a&gt; further because they do some unique things when it comes to mutability.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sets and Maps
&lt;/h3&gt;

&lt;p&gt;These are relative newcomers in the land of JavaScript, but they're great tools to have at your disposal. When developing in Rust you'll get similar functionality from &lt;a href="https://doc.rust-lang.org/std/collections/struct.HashSet.html"&gt;HashSets&lt;/a&gt; and &lt;a href="https://doc.rust-lang.org/std/collections/hash_map/struct.HashMap.html"&gt;HashMaps&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note that there are also BTree based implementations of these structures.&lt;/p&gt;

&lt;h3&gt;
  
  
  Function
&lt;/h3&gt;

&lt;p&gt;As with JavaScript, Rust has first-class functions. In addition to functions, defined using the &lt;code&gt;fn&lt;/code&gt; keyword, Rust also has closures. Closures are anonymous functions with syntax that looks similar to JavaScript arrow functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is that it?
&lt;/h2&gt;

&lt;p&gt;JavaScript is pretty minimal when it comes to types. Especially when compared to more verbose languages like Java or C. Rust's offerings are more similar to the latter, so things like Linked Lists are available as a type in Rust.&lt;/p&gt;

&lt;p&gt;If you can't find what you're looking for the docs are great! And so is the community. With a little bit of trial and error you'll get what you need.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Setting up my new Machine</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Fri, 09 Apr 2021 13:56:03 +0000</pubDate>
      <link>https://dev.to/laurieontech/setting-up-my-new-machine-549i</link>
      <guid>https://dev.to/laurieontech/setting-up-my-new-machine-549i</guid>
      <description>&lt;p&gt;I started my new job this week, and that meant setting up a new machine. I have a set of tools that I'm comfortable with, so choosing what to download wasn't complicated.&lt;/p&gt;

&lt;p&gt;What I did find interesting is the tools I "just had to have" and those I haven't yet configured yet. A lot of my choices are available on my &lt;a href="https://laurieontech.com/uses/"&gt;uses page&lt;/a&gt;, but it also needs an update.&lt;/p&gt;

&lt;p&gt;So with that, I'm going to talk through my must-haves this past week!&lt;/p&gt;

&lt;h2&gt;
  
  
  Terminal
&lt;/h2&gt;

&lt;p&gt;Over the years, my terminal has become my programming control center. Who would have thought! When I first started doing development work, I was incredibly intimidated by the command line. I suppose building CLIs will rid you of that fear 🤷.&lt;/p&gt;

&lt;p&gt;As it turns out, my terminal setup requires a lot of things. Oops!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://iterm2.com/"&gt;iterm2&lt;/a&gt;: I find this a nicer option than the built-in apple terminal.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://ohmyz.sh/"&gt;oh-my-zsh&lt;/a&gt;: All my machines use this and I've gotten comfortable with it rather than bash.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://starship.rs/"&gt;starship&lt;/a&gt;: This is a newer tool for me but I love the information-rich command prompts and the overall look.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once the look and feel of my terminal was ready, I needed additional software.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://brew.sh/"&gt;homebrew&lt;/a&gt;: The essential package manager for macOS.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/nvm-sh/nvm"&gt;nvm&lt;/a&gt;: My JavaScript-loving heart can't live without it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also set up Xcode command line tools so I could get git working. But that was most of my first week essentials in terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Apps
&lt;/h2&gt;

&lt;p&gt;Now it was time to get my most-used applications. My machine came preloaded with &lt;a href="https://slack.com/"&gt;Slack&lt;/a&gt;, so I didn't need to worry about that. But there were a handful of other things I wanted right away.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://code.visualstudio.com/"&gt;VS Code&lt;/a&gt;: My IDE of choice. I'll dive into this more in a moment.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://magnet.crowdcafe.com/"&gt;Magnet&lt;/a&gt;: I actually didn't download this until day three and was wondering why my monitor was bugging me so much. Windows managers are so key!&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://help.elgato.com/hc/en-us/sections/360004115951-Elgato-Control-Center-Software"&gt;Elgato Control Center&lt;/a&gt;: This is how I control my lighting setup and make my video chats higher quality.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.getclockwise.com/"&gt;Clockwise&lt;/a&gt;: I technically downloaded the chrome extension and integrated it with Slack, but close enough. Calendar tools are a first-week necessity.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://chrome.google.com/webstore/detail/google-docs-dark-mode/lgjhepbpjcmfmjlpkkdjlbgomamkgonb?hl=en"&gt;Google Doc dark mode&lt;/a&gt;: Another chrome extension, but this one helps my eyes a ton when I'm trying to do a lot of deep focus reading.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's a surprisingly low number of apps. I'm sure it'll grow in the coming weeks.&lt;/p&gt;

&lt;h2&gt;
  
  
  VS Code
&lt;/h2&gt;

&lt;p&gt;Now we get to the really good stuff. I'm a developer after all! As it turns out, I didn't do much coding in this first week, but I did look at a lot of existing projects. So what were my go-to extensions?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ESLint&lt;/li&gt;
&lt;li&gt;Prettier&lt;/li&gt;
&lt;li&gt;Bracket Pair Colorizer&lt;/li&gt;
&lt;li&gt;Indent Rainbow&lt;/li&gt;
&lt;li&gt;JavaScript and Typescript&lt;/li&gt;
&lt;li&gt;Peacock&lt;/li&gt;
&lt;li&gt;Monokai theme&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's the current list! It'll get longer, but you can already tell that it's focused on readability. I don't necessarily know what functional helpers I'll need yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Yay first week!
&lt;/h2&gt;

&lt;p&gt;So that's my current computer setup. It's connected to all my existing hardware and you can read more about that on my &lt;a href="https://laurieontech.com/uses/"&gt;uses page&lt;/a&gt;. Thus far, I've done a lot of reading, had plenty of onboarding chats about logistics, and started to get a handle on what my new role is. Excited for what's to come.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>vscode</category>
    </item>
    <item>
      <title>If Your Tech Interview is Three Tech Interviews in a Trench Coat and I Do Five is It Additive or Exponential</title>
      <dc:creator>Laurie</dc:creator>
      <pubDate>Mon, 29 Mar 2021 13:10:47 +0000</pubDate>
      <link>https://dev.to/laurieontech/if-your-tech-interview-is-three-tech-interviews-in-a-trench-coat-and-i-do-five-is-it-additive-or-exponential-244g</link>
      <guid>https://dev.to/laurieontech/if-your-tech-interview-is-three-tech-interviews-in-a-trench-coat-and-i-do-five-is-it-additive-or-exponential-244g</guid>
      <description>&lt;p&gt;I want to warn you all ahead of time. This is going to be a lengthy post. So feel free to take it in chunks. I also want to add that this post is filled with privilege. At no point during this process did I fear losing my job, my basic needs were always more than met, and I'm a white cis woman. This is a narrative of my experience and the lessons I learned along the way. It is not meant as universal tips for the job search process. That's deeply personal.&lt;/p&gt;

&lt;p&gt;There are a large number of people in tech who subscribe to the "you should always be interviewing" mentality. To be honest, I've never been one of them. If you've been around me much, you know that I'm not fond of how we interview in this industry. So it makes sense that I wouldn't choose to subject myself to that process for no reason.&lt;/p&gt;

&lt;p&gt;That being said, I opted to begin a job search around six months ago. What did that mean for me? It meant I told some friends privately that I was willing to entertain opportunities. And if I saw something appealing, I'd apply.&lt;/p&gt;

&lt;p&gt;That's where our story starts. This post will include lessons I learned as a job seeker. As well as patterns I hope companies will address.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Quick note. I receive a LOT of recruiter inbound. Of the companies I mention in this post, only a few of them were places I considered because of unsolicited outreach. I'm far more likely to rely on the recommendations of friends.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  My Network has grown
&lt;/h2&gt;

&lt;p&gt;I've not "searched" for jobs in some time. The last time was my first full-time coding job where I interviewed at nine different companies. From there, I fell into another opportunity. And when I joined Gatsby I had only applied to that specific role.&lt;/p&gt;

&lt;p&gt;The last few years have been a lot of fun as I've gotten to broaden my reach in the JavaScript ecosystem and meet a lot of incredible people. To be honest, I hadn't realized what that would mean should I ever look for a new role.&lt;/p&gt;

&lt;p&gt;My search quickly became overwhelming. My friends, who are awesome and I thank them, sent me so many leads and connected me with even more people. I wound up with five or so concrete interview opportunities within a week. And in the end, I went through two distinct periods of interviewing with a break in between. Let's talk about how that played out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Search Part I
&lt;/h2&gt;

&lt;p&gt;We'll start with the first "phase" of interviews, the initial five companies. For two companies, the process ended after the first conversation. One was on my side--I couldn't go through five processes at once. I was working a full-time job. The second was on their side. They liked me, but they'd just closed the role with someone else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LESSON #1&lt;/strong&gt;&lt;br&gt;
The first qualified candidate through the process will get hired. If there is a difference of under a week they may hold off, but not always. Find out if you're part of a search for a single seat and what their timeline is.&lt;/p&gt;

&lt;p&gt;Now for the other three opportunities! I'll start by saying I made it to final rounds for all of them. And I didn't get offers from any of them. Demoralizing? Yes. Exhausting? Without a doubt. I'm not going to name specific companies, but I will talk about each of those experiences individually.&lt;/p&gt;

&lt;h3&gt;
  
  
  Company A
&lt;/h3&gt;

&lt;p&gt;This was my first technical interview process in quite some time. I coded in front of them in at least three interviews. One went well, one I thought went well (we'll get to that in a second), one went poorly.&lt;/p&gt;

&lt;p&gt;They had a two-part final round and called me the night after part one to cancel the following day. I genuinely appreciate them not wasting more of my time.&lt;/p&gt;

&lt;p&gt;But let's talk about how we got there in the first place. Their interviews were very tool-user specific. This was for a tech lead role that would need to help guide the team to solve problems, use more scalable practices, and yes, code.&lt;/p&gt;

&lt;p&gt;Their interviews focused on whether I put curly braces in the right place on the first try (and yes, that was actually part of the feedback). I had told them prior to the interview that I was working in the frontend ecosystem in a very niche area! That some of my generic frontend skills were rusty. But sometimes, even when you set expectations, there is a clear disconnect.&lt;/p&gt;

&lt;p&gt;You won't be surprised to hear that this experience inspired my &lt;a href="https://laurieontech.com/posts/senior-interviews/"&gt;senior interviews post&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Company B
&lt;/h3&gt;

&lt;p&gt;Fun fact, this would not be the only time I interviewed with this company in the six-month period, but this was the first.&lt;/p&gt;

&lt;p&gt;The full interview process involved eleven conversations when all was said and done. To be honest, I made some mistakes here and I think they're important to talk about.&lt;/p&gt;

&lt;p&gt;The job seemed perfect at first! But as the process went on I realized it was very systems architecture heavy. And I ignored that. Choosing to move forward because they were moving me forward. It wasn't the right job for me, we both knew it, but neither party wanted to admit it.&lt;/p&gt;

&lt;p&gt;Was that a bad thing? Well, yes. Because I didn't have the right kind of experience for what they were indexing on (there were other parts of the job I could do well), they added extra interviews on that subject. They wanted to be super sure I couldn't do the job! Because they liked me! And that sucked.&lt;/p&gt;

&lt;p&gt;It seemed like everyone was being nice and giving me my fair shot. But in reality, we all knew I didn't have that skill at the level they wanted. So it wasn't super fair to keep putting me through those extra interviews.&lt;/p&gt;

&lt;p&gt;I also froze in one of the early interviews on that subject. I can normally BS and talk through most situations, even when I'm terrified. I couldn't in this scenario. I suspect this is a big reason they opted to add additional interviews--in case it really was just nerves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LESSON #2&lt;/strong&gt; The company may be awesome. You may want it to work. But if the interviews are focused on things you don't like/aren't good at AND you've confirmed that matches the tasks of the role, drop out.&lt;/p&gt;

&lt;h3&gt;
  
  
  Company C
&lt;/h3&gt;

&lt;p&gt;I'll state up front that this was my most frustrating interview experience. And I'm still not pleased with how it went. I applied for a staff-level position, had an initial call, and was fast-tracked to their final interview process. Awesome!&lt;/p&gt;

&lt;p&gt;This company does generic interviews for candidates at that level (they're not alone, I'll touch on this later). The problem was how this played out. I was applying for a somewhat specialist position. As I moved through conversations and they didn't seem to match the role at all, I'd ask "is this type of work part of what I'll be doing in this position"? 3/4 interviewers didn't know what I was interviewing for. 2/4 looked it up and hadn't heard of the team.&lt;/p&gt;

&lt;p&gt;I would never recommend a company do this for so many reasons. I knew as soon as I left the final conversation I hadn't met the bar. Because the bar didn't even make sense. Plus, I was exhausted (we'll hit on that in a moment too).&lt;/p&gt;

&lt;p&gt;When the recruiter emailed me she mentioned how amazing I clearly was and that she was sure I'd land somewhere great. I had a sense she was stunned I could tank their interview so badly when it was clear I had experience. Tech is big! People can't know everything. So don't interview them for things you aren't hiring them for.&lt;/p&gt;

&lt;p&gt;Now to the exhausted point. I was exhausted. This was the last of my processes. I was doing interviews almost exclusively in west coast time because I had a day job. If I recall correctly, that final round started at 6 pm on a Friday night for me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LESSON #3&lt;/strong&gt;&lt;br&gt;
Interviews when you're tired put you at a disadvantage. Schedule them as best you can to prevent that eventuality. And if there are jobs you don't want? Drop out and save your energy for the ones you do.&lt;/p&gt;

&lt;h2&gt;
  
  
  So where does that leave us?
&lt;/h2&gt;

&lt;p&gt;And that was the first stretch of interview processes I went through! By this point it was Fall. I was moving. The holidays were coming up. I was exhausted. I'd followed through on the initial leads and nothing had panned out. So I stopped.&lt;/p&gt;

&lt;p&gt;This is the absolute best thing I could have done for myself. I had barely made it through some of the end rounds with my mental health. It was a pandemic still. Work had been really busy, and a bunch of my friends had left.&lt;/p&gt;

&lt;p&gt;As I was about to take two weeks off for the holidays, something shifted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Search Part II
&lt;/h2&gt;

&lt;p&gt;I still hadn't told any additional people I was looking beyond the original handful. But apparently, the end of 2020 meant a lot of roles were about to open up.&lt;/p&gt;

&lt;p&gt;All of a sudden I was contacted for, referred to, and otherwise told about over a dozen roles. I won't go through each of these individually, but I'll capture the highlights.&lt;/p&gt;

&lt;h3&gt;
  
  
  Company D
&lt;/h3&gt;

&lt;p&gt;I was so so excited about this role. I didn't start an official interview process, it was all conversations about me, my background, what the role entailed, if I was interested in it.&lt;/p&gt;

&lt;p&gt;But part of the reason I didn't interview was because they didn't want to put me through that until they were sure they could hire me. In the end, they couldn't. They didn't have the right headcount in the right places. But the company treated me as a human and an individual. Timing didn't line up but if they came back in the future I certainly might consider working there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LESSON #4&lt;/strong&gt;&lt;br&gt;
Timing is everything. A company may contact you to interview just as you're about to accept an offer. You may find an amazing role that would be perfect for past you, or future you, but not current you. It's frustrating, but it's good to recognize that a lot of job searching is out of your control.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Start-Ups
&lt;/h3&gt;

&lt;p&gt;This is not an entirely fair grouping, but there were three companies in my space that had various roles they were interested in me for. I took those conversations, sometimes going a bit further into the process.&lt;/p&gt;

&lt;p&gt;The problem was I sort of knew that wasn't what I wanted for my next step. But it took me a while to feel confident in that and walk away from those processes. And I had too much going on at the time too, so that forced my hand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LESSON #5&lt;/strong&gt;&lt;br&gt;
It's really hard to say no. Like, really hard. Especially when the company is small and you don't feel like just another number. But it's best for everyone that you do. Even if you were referred to the role. Be respectful and fair.&lt;/p&gt;

&lt;h3&gt;
  
  
  The repeats
&lt;/h3&gt;

&lt;p&gt;This may seem surprising, but there were a lot of companies I talked to more than once, for different roles. Some didn't move quickly enough before I had another offer I wanted to take. In other cases the role wasn't right the second time around, so I dropped out.&lt;/p&gt;

&lt;p&gt;Talking to places twice was great because they tried to limit the conversations I'd already had. And they were keyed into the type of work I wanted to do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LESSON #6&lt;/strong&gt;&lt;br&gt;
There will always be another role open at a company eventually. Don't burn bridges if things don't work out the first time around. And don't be afraid to apply to a new listing even if it's at a company you just completed a process with.&lt;/p&gt;

&lt;h3&gt;
  
  
  The title "cuts"
&lt;/h3&gt;

&lt;p&gt;This one is interesting and was a part of the conversation at a lot of different companies, but two in particular. These companies had openings for roles with a specific level in mind, rather than a sliding scale that they'd peg to the candidate in question.&lt;/p&gt;

&lt;p&gt;That was great information to have upfront! I decided not to pursue either role in the end, though the level misalignment was not ultimately a factor in those decisions. One was a timing thing. The other had a bad reputation for women when I asked around.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LESSON #7&lt;/strong&gt;&lt;br&gt;
Make sure to use your network and ask around about companies you're considering. Typically you'll do this research before applying, but recruiter inbound is different. This is especially important as a minoritized individual; be sure to get a clear picture of the company culture before investing too much time in the process.&lt;/p&gt;

&lt;p&gt;But let's get back to the title cut conversations. Knowing the company had a specific level in mind ahead of time was a perfectly reasonable explanation. Unfortunately, there was more than one place I spoke with where the recruiter opened with "you may have to take a title cut" and no further explanation. They were projecting what they thought my experience would count as before interviewing me in any capacity. That was a red flag.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LESSON #8&lt;/strong&gt;&lt;br&gt;
There can be a lot of reasons for titles, compensation, etc. Make sure you know why. Context does matter.&lt;/p&gt;

&lt;h2&gt;
  
  
  The offers
&lt;/h2&gt;

&lt;p&gt;Now we're getting to the final two. The places where I chose to go through all the interviews and ultimately received offers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Company E
&lt;/h3&gt;

&lt;p&gt;Another generic interview! I told you we'd come back to this. But this one was done really well! All the rounds were applicable to my skills, everyone knew what types of signals they were looking for, etc.&lt;/p&gt;

&lt;p&gt;But I still don't like generic interviews. While this experience was far better, it left the team match until the end. It was essentially, "if we like you, we'll find where you fit when we're done". That meant a lot of time was put into a process for a job I didn't know anything about.&lt;/p&gt;

&lt;p&gt;And in the end, I really liked the company. But finding the right team and the right manager felt like a burden I was putting on them, dragging out the process. That wasn't a great way to feel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LESSON #9&lt;/strong&gt;&lt;br&gt;
Always take your time and do your research after you're given an offer. If the company tries to rush you, be wary. However, see my note about privilege at the beginning. You may not be able to do this, and that's perfectly ok.&lt;/p&gt;

&lt;h3&gt;
  
  
  Company F
&lt;/h3&gt;

&lt;p&gt;This was a repeat process so they nixed a few interviews. But the role was in such a different technical area than the first process that it was hard to do more than that. What's interesting about this process was that I was in touch with the hiring manager throughout. I spoke to him early on and checked back in for ~15-minute calls between almost every set of rounds. This was unique among the places I interviewed. In most cases, I'd meet the hiring manager once. And in at least one process they planned to hire me without having met them at all!&lt;/p&gt;

&lt;p&gt;Another interesting part of this process was they were clearly aware of the possibility that I may not choose to work there. This is always true, but rarely is it acknowledged in a scenario where companies hold a lot more power than candidates. This meant that they asked me a lot of questions about what I wanted to do, raised concerns they saw about where the role may not match my needs, etc. I felt confident by the end that I knew what to expect.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LESSON #10&lt;/strong&gt;&lt;br&gt;
You will almost always have more questions than they give you the time to ask. If you don't feel like you have a good sense of the role, or the team, or the company, or anything else you want to know, make sure you have someone you can follow up with asynchronously.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Patterns
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Every final process included multiple interviews. And each time they'd talk about how each of those interviews was focused on different skills/questions. Yet they consistently repeated questions and I repeated examples/anecdotes. This is a frustrating waste of time that we should address as an industry.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interviewers need to know the skills they're looking for in a candidate or they shouldn't be interviewing them. One size fits all makes zero sense for a company of a certain size, regardless of the level targeted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The tool user problem I talk about in my senior engineers post is absolutely real. The best interviews I had included only one hands-on coding task and you passed based on your approach to the problem, rather than familiarity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There were some red flags I witnessed that I think are worth writing down. They may not be flags to everyone, but they were to me.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Using the term "famous" or "superstar" as a way to appeal to me as a hire. It made me worry about what criteria they were using for the team/company.&lt;/li&gt;
&lt;li&gt;Mentioning that I would help them break the mold of a homogenous team based on friends of friends. I had no interest in being a guinea pig.&lt;/li&gt;
&lt;li&gt;Managers who made it clear they'd rather be ICs and used their time accordingly. Not someone I want helping me navigate the next stages of my career.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There were others, but those three stick in my brain.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what's next?
&lt;/h2&gt;

&lt;p&gt;I'm starting a new job next week! I'll probably mention where in the next few days. But I wanted to focus on the process first. I truly hope it's useful to see this all written down.&lt;/p&gt;

&lt;p&gt;It took a considerable amount of time to find a company I wanted to work for, with a role I was interested in, where the timing aligned. There were times it existed and I didn't pass muster. It was a hard and tiring process but I'll leave you with one final lesson.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LESSON #11&lt;/strong&gt;&lt;br&gt;
People tell you to always be interviewing because the tech industry has turned interviewing into its own skill that you can get rusty at. If you don't want to do that--I didn't--make sure the company you’re most interested in isn’t the one you interview with first. Give yourself a true trial run, with real stakes, to stretch those interviewing muscles. By the time I got to the second phase of companies, I was seeing exercises I'd already seen and solved.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Summary
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The first qualified candidate through the process will get hired. If there is a difference of under a week they may hold off, but not always. Find out if you're part of a search for a single seat and what their timeline is.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The company may be awesome. You may want it to work. But if the interviews are focused on things you don't like/aren't good at AND you've confirmed that matches the tasks of the role, drop out.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interviews when you're tired put you at a disadvantage. Schedule them as best you can to prevent that eventuality. And if there are jobs you don't want? Drop out and save your energy for the ones you do.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Timing is everything. A company may contact you to interview just as you're about to accept an offer. You may find an amazing role that would be perfect for past you, or future you, but not current you. It's frustrating, but it's good to recognize that a lot of job searching is out of your control.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's really hard to say no. Like, really hard. Especially when the company is small and you don't feel like just another number. But it's best for everyone that you do. Even if you were referred to the role. Be respectful and fair.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There will always be another role open at a company eventually. Don't burn bridges if things don't work out the first time around. And don't be afraid to apply to a new listing even if it's at a company you just completed a process with.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make sure to use your network and ask around about companies you're considering. Typically you'll do this research before applying, but recruiter inbound is different. This is especially important as a minoritized individual; be sure to get a clear picture of the company culture before investing too much time in the process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There can be a lot of reasons for titles, compensation, etc. Make sure you know why. Context does matter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Always take your time and do your research after you're given an offer. If the company tries to rush you, be wary. However, see my note about privilege at the beginning. You may not be able to do this, and that's perfectly ok.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will almost always have more questions than they give you the time to ask. If you don't feel like you have a good sense of the role, or the team, or the company, or anything else you want to know, make sure you have someone you can follow up with asynchronously.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;People tell you to always be interviewing because the tech industry has turned interviewing into its own skill that you can get rusty at. If you don't want to do that--I didn't--make sure the company you’re most interested in isn’t the one you interview with first. Give yourself a true trial run, with real stakes, to stretch those interviewing muscles. By the time I got to the second phase of companies, I was seeing exercises I'd already seen and solved.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>career</category>
      <category>interviewing</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
