<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Amber: Learn</title>
  <subtitle>Mini-posts on things I learn as a developer.</subtitle>
  <link href="https://amberwilson.co.uk/learn.xml" rel="self"/>
  <link href="https://amberwilson.co.uk/learn/"/>
  <updated>Tue, 17 Mar 2026 08:54:14 GMT</updated>
  <id>https://amberwilson.co.uk/learn/</id>
  <author>
    <name>Amber Wilson</name>
  </author>
  
    
    <entry>
      <title>Font Subsetting</title>
      <link href="https://amberwilson.co.uk/learn/font-subsetting/"/>
      <updated>2020-11-21T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/font-subsetting/</id>
      <content type="html">&lt;p&gt;At the time of writing this, I am self-hosting four separate font files (for 2 different fonts) on my site. That&#39;s quite a lot.&lt;/p&gt;
&lt;p&gt;I did make sure they are &lt;code&gt;woff2&lt;/code&gt; format so they are as small as possible - only around 20kb each. The same fonts in &lt;code&gt;ttf&lt;/code&gt; format can be over 200kb each. Still, with 4 font files, there is a hefty 80kb of fonts, and four separate network requests for them.&lt;/p&gt;
&lt;p&gt;One of the fonts, Rubik 900, is used only in my site&#39;s navigation:&lt;/p&gt;
&lt;img src=&quot;https://amberwilson.co.uk/learn/img/navigation.png&quot; alt=&quot;navigation link text&quot; /&gt;
&lt;p&gt;So, I wondered if I could reduce the font file to only contain the characters that my navigation needs. The answer? &lt;strong&gt;Yes!&lt;/strong&gt; 🎉&lt;/p&gt;
&lt;p&gt;It is possible to &lt;strong&gt;subset&lt;/strong&gt; a font file. I used &lt;a href=&quot;https://www.fontsquirrel.com/tools/webfont-generator&quot;&gt;font squirrel&#39;s webfont generator&lt;/a&gt; to do this.&lt;/p&gt;
&lt;p&gt;Font squirrel only wanted to accept the &lt;code&gt;tff&lt;/code&gt; version of my Rubik 900 font file, so I uploaded that into the generator. I then chose &#39;expert&#39;, and under &#39;subsetting&#39; I chose &#39;custom subsetting&#39;. After this, I copied and pasted my navigation text into the &#39;single characters&#39; option:&lt;/p&gt;
&lt;img src=&quot;https://amberwilson.co.uk/learn/img/subsetting.png&quot; alt=&quot;subsetting with font squirrel&quot; /&gt;
&lt;p&gt;The generator immediately showed me a &#39;subset preview&#39; of the characters my font file would now contain.&lt;/p&gt;
&lt;p&gt;I wasn&#39;t so sure which options to pick from the rest of the form. If you want a more in-depth explanation of how to subset with the generator, please see this post on &lt;a href=&quot;https://publishing-project.rivendellweb.net/subsetting-fonts/&quot;&gt;subsetting fonts with font squirrel&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I took the freshly-subsetted font that I had downloaded from font squirrel, and took a look at the file size. It was only 3.5kb! This is a saving of 16.5kb or ~82%!&lt;/p&gt;
&lt;p&gt;I added the subsetted font file to my code, and the navigation text still looked and worked just the same as before.&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Spread Syntax</title>
      <link href="https://amberwilson.co.uk/learn/spread-syntax/"/>
      <updated>2020-03-18T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/spread-syntax/</id>
      <content type="html">&lt;p&gt;New in ES6 were the three dots &lt;code&gt;...&lt;/code&gt; known as the spread syntax. It&#39;s the evolution of &lt;code&gt;sum.apply&lt;/code&gt;. Spread syntax can do a lot more than I can explain in this little post. All I want to share is one way it helped me greatly in real life recently. Consider the following code:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; list &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; groceryList &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;item1&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;bread&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;item2&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;flowers&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; catToys &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;toy1&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;jingly ball&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;toy2&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;catnip mouse&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

list &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;groceryList&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;catToys &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;list&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// {item1: &quot;bread&quot;, item2: &quot;flowers&quot;, toy1: &quot;jingly ball&quot;, toy2: &quot;catnip mouse&quot;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It merges two objects into one! Sadly, it won&#39;t work if any keys in either object are the same. In such a case, the last instances of keys that are repeated would be used and the duplicates discarded.&lt;/p&gt;
&lt;p&gt;One more cool thing I&#39;ll mention is that spread syntax can merge the values of a good old array:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;let&lt;/span&gt; numbers &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; catRatings &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; dogRatings &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

numbers &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;dogRatings&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;catRatings&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;numbers&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// [(12, 11, 14, 10, 10, 12, 14, 11)]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The numbers are all placed in one array! Even duplicated ones. If numbers was then re-assigned to an object, the duplicated numbers would be removed:&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;numbers &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;dogRatings&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;catRatings &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;numbers&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token comment&quot;&gt;// {0: 10, 1: 12, 2: 14, 3: 11}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In conclusion to this small post - the spread syntax is really useful for manipulating values in a clean and understandable way. It can be used to concatenate values of different arrays or objects, and it can also flatten nested arrays or objects! Check out this post for a &lt;a href=&quot;https://www.freecodecamp.org/news/an-introduction-to-spread-syntax-in-javascript-fba39595922c/&quot;&gt;visual list of uses for the spread syntax&lt;/a&gt;. The post&#39;s page isn&#39;t too accessible but hey, let this be a lesson to give your images alt attributes!&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>filter</title>
      <link href="https://amberwilson.co.uk/learn/filter/"/>
      <updated>2019-10-01T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/filter/</id>
      <content type="html">&lt;p&gt;Howdy, sorry for the long hiatus. I was busy... planning an underwater holiday park. Nah, I was working hard and getting a little too much imposter syndrome. But now I&#39;ve taken some helpful advice from myself to cut all that out and acknowledge the brilliant and hardworking developer that I am! And you should do the same. It does wonders for your self-esteem and sanity :)&lt;/p&gt;
&lt;p&gt;Anyway, I&#39;ve been playing with some Codewars katas and getting into the &lt;code&gt;Array.prototype.filter()&lt;/code&gt; method in JS, and I like it. It&#39;s an almost disturbingly simple way to get some things done.&lt;/p&gt;
&lt;p&gt;I was scratching my head about how to complete this task today:&lt;/p&gt;
&lt;p&gt;Return an array that contains all values of array &lt;code&gt;a&lt;/code&gt;, apart from those that exist in array &lt;code&gt;b&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;arrayA &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
arrayB &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

newArray &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// &amp;lt;- make this magic happen!&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What &lt;code&gt;filter&lt;/code&gt; does for you is filter out any value you wish. You can attach the fitler method to an array, give it a condition, and it will return everything in the array that matches the condition. Note: when I first began using filter, I thought it would remove all values that match the condition, however the values that match the condition are actually kept. This seems a little unintuitive to me, but hey, I didn&#39;t write JS ;)&lt;/p&gt;
&lt;p&gt;Here is &lt;s&gt;the&lt;/s&gt; a solution:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;newArray &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; arrayA&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;arrayB&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;includes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;value&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In it, we are taking each value of &lt;code&gt;arrayA&lt;/code&gt; and if &lt;code&gt;arrayB&lt;/code&gt; contains any of these values, we do not display them in our &lt;code&gt;newArray&lt;/code&gt;. If the &lt;code&gt;!&lt;/code&gt; was not present, we would create an array containing the values of &lt;code&gt;arrayB&lt;/code&gt; that match values in &lt;code&gt;arrayA&lt;/code&gt; (i.e. &lt;code&gt;[2, 2, 2]&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Using the &lt;code&gt;filter&lt;/code&gt; method takes time to get your head around, but it&#39;s worth it! Play around with the example above in your browser console. Also note the &lt;code&gt;Array.prototype.includes()&lt;/code&gt; method being used in the example. I will cover this next time. Over and out for now.&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Console debugging</title>
      <link href="https://amberwilson.co.uk/learn/console-debugging/"/>
      <updated>2019-07-25T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/console-debugging/</id>
      <content type="html">&lt;p&gt;A lot of people use &lt;code&gt;console.log&lt;/code&gt; to debug in the console.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;log()&lt;/code&gt; method of &lt;code&gt;console&lt;/code&gt; logs things to the web console. What some people may not know is that you can log things in nice ways! Here are three:&lt;/p&gt;

      &lt;div class=&quot;heading-wrapper&quot;&gt;
        &lt;h2 id=&quot;1.-computed-property-names--&quot;&gt;1. Computed property names -
      &lt;/h2&gt;
        &lt;a class=&quot;anchor-link&quot; href=&quot;https://amberwilson.co.uk/learn/console-debugging/#1.-computed-property-names--&quot;&gt;
          &lt;span class=&quot;anchor-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg height=&quot;16&quot; version=&quot;1.1&quot; viewBox=&quot;0 0 16 16&quot; width=&quot;16&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;
    &lt;path fill-rule=&quot;evenodd&quot; d=&quot;M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z&quot; fill=&quot;currentcolor&quot;&gt;&lt;/path&gt;
  &lt;/svg&gt;&lt;/span&gt;
          &lt;span class=&quot;hidden&quot;&gt;Section titled 1. Computed property names -&lt;/span&gt;
        &lt;/a&gt;
      &lt;/div&gt;&lt;p&gt;The following objects could be logged one at a time:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; cat &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Fluffy&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;colour&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;orange&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;specialSkill&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;staring&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; dog &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Thor&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;colour&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;brown&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;specialSkill&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;running&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; fish &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Glub&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;colour&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;blue&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;specialSkill&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;blowing bubbles&#39;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And the results would be as follows:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;cat&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// {name: &quot;Fluffy&quot;, colour: &quot;orange&quot;, specialSkill: &quot;staring&quot;}&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dog&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// {name: &quot;Thor&quot;, colour: &quot;brown&quot;, specialSkill: &quot;running&quot;}&lt;/span&gt;
console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;fish&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// {name: &quot;Glub&quot;, colour: &quot;blue&quot;, specialSkill: &quot;blowing bubbles&quot;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or, they could be logged with a name label using &#39;computed property names&#39;. To do this, create an object with the variables as keys:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; cat&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; dog&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; fish &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// {cat: {…}, dog: {…}, fish: {…}}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Inside this object, there will be the details of each variable with its corresponding key:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token literal-property property&quot;&gt;cat&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Fluffy&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;colour&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;orange&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;specialSkill&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;staring&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token literal-property property&quot;&gt;dog&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Thor&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;colour&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;brown&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;specialSkill&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;running&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token literal-property property&quot;&gt;fish&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;token literal-property property&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Glub&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;colour&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;blue&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token literal-property property&quot;&gt;specialSkill&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;blowing bubbles&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

      &lt;div class=&quot;heading-wrapper&quot;&gt;
        &lt;h2 id=&quot;2.-css-in-the-console--&quot;&gt;2. CSS in the console -
      &lt;/h2&gt;
        &lt;a class=&quot;anchor-link&quot; href=&quot;https://amberwilson.co.uk/learn/console-debugging/#2.-css-in-the-console--&quot;&gt;
          &lt;span class=&quot;anchor-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg height=&quot;16&quot; version=&quot;1.1&quot; viewBox=&quot;0 0 16 16&quot; width=&quot;16&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;
    &lt;path fill-rule=&quot;evenodd&quot; d=&quot;M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z&quot; fill=&quot;currentcolor&quot;&gt;&lt;/path&gt;
  &lt;/svg&gt;&lt;/span&gt;
          &lt;span class=&quot;hidden&quot;&gt;Section titled 2. CSS in the console -&lt;/span&gt;
        &lt;/a&gt;
      &lt;/div&gt;&lt;p&gt;Define styles like this in the console:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; styles &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&#39;background: linear-gradient(#21618C, #5DADE2)&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&#39;padding: 5px&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&#39;border-radius: 8px&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&#39;text-align: center&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&#39;color: white&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&#39;display: block&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;;&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then prefix console log with the &lt;code&gt;%c&lt;/code&gt; flag, adding the &lt;code&gt;styles&lt;/code&gt; variable to the end:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;token template-string&quot;&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;%c My cat is &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;cat&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;name&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;cat&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;colour&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;token interpolation&quot;&gt;&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;${&lt;/span&gt;cat&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;specialSkill&lt;span class=&quot;token interpolation-punctuation punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token template-punctuation string&quot;&gt;`&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  styles
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Try it in your console or look at &lt;a href=&quot;https://codesandbox.io/embed/determined-wozniak-4lt93&quot;&gt;this&lt;/a&gt; example on CodeSandbox!&lt;/p&gt;

      &lt;div class=&quot;heading-wrapper&quot;&gt;
        &lt;h2 id=&quot;3.-tables-in-the-console--&quot;&gt;3. Tables in the console -
      &lt;/h2&gt;
        &lt;a class=&quot;anchor-link&quot; href=&quot;https://amberwilson.co.uk/learn/console-debugging/#3.-tables-in-the-console--&quot;&gt;
          &lt;span class=&quot;anchor-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg height=&quot;16&quot; version=&quot;1.1&quot; viewBox=&quot;0 0 16 16&quot; width=&quot;16&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;
    &lt;path fill-rule=&quot;evenodd&quot; d=&quot;M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z&quot; fill=&quot;currentcolor&quot;&gt;&lt;/path&gt;
  &lt;/svg&gt;&lt;/span&gt;
          &lt;span class=&quot;hidden&quot;&gt;Section titled 3. Tables in the console -&lt;/span&gt;
        &lt;/a&gt;
      &lt;/div&gt;&lt;p&gt;To display objects in a table in order to more easily compare them, try using &lt;code&gt;console.table&lt;/code&gt;. You can do so with the animal objects above by running:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;table&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;cat&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; dog&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; fish&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Not only will there be a nicely-formatted table to see in the console, but the (unlabeled) objects will also be displayed as well.&lt;/p&gt;

      &lt;div class=&quot;heading-wrapper&quot;&gt;
        &lt;h2 id=&quot;note&quot;&gt;Note
      &lt;/h2&gt;
        &lt;a class=&quot;anchor-link&quot; href=&quot;https://amberwilson.co.uk/learn/console-debugging/#note&quot;&gt;
          &lt;span class=&quot;anchor-icon&quot; aria-hidden=&quot;true&quot;&gt;&lt;svg height=&quot;16&quot; version=&quot;1.1&quot; viewBox=&quot;0 0 16 16&quot; width=&quot;16&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;
    &lt;path fill-rule=&quot;evenodd&quot; d=&quot;M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z&quot; fill=&quot;currentcolor&quot;&gt;&lt;/path&gt;
  &lt;/svg&gt;&lt;/span&gt;
          &lt;span class=&quot;hidden&quot;&gt;Section titled Note&lt;/span&gt;
        &lt;/a&gt;
      &lt;/div&gt;&lt;p&gt;All of these things make console logging a little better. Not sure how many I will start using myself, but I&#39;ll give them a go to see whether I like them :)&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Types</title>
      <link href="https://amberwilson.co.uk/learn/types/"/>
      <updated>2019-07-16T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/types/</id>
      <content type="html">&lt;p&gt;JavaScript has six primitive types. These all have default values and can be checked for using the &lt;code&gt;typeof&lt;/code&gt; operator.&lt;/p&gt;
&lt;p&gt;Default values:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token string&quot;&gt;&#39;boolean&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;token string&quot;&gt;&#39;null&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;null&lt;/span&gt;
&lt;span class=&quot;token string&quot;&gt;&#39;number&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;token string&quot;&gt;&#39;string&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;&#39;&lt;/span&gt;
&lt;span class=&quot;token string&quot;&gt;&#39;undefined&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;token string&quot;&gt;&#39;symbol&#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;Symbol&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// new in ES6&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Checking the type of a primitive:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;typeof&lt;/span&gt; myPrimitive &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;number&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;TypeError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Type must be a number!&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
</content>
    </entry>
    
    <entry>
      <title>Prebrowsing</title>
      <link href="https://amberwilson.co.uk/learn/prebrowsing/"/>
      <updated>2019-06-15T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/prebrowsing/</id>
      <content type="html">&lt;p&gt;This is an umbrella term for telling browsers what users need (and allowing preloading of data) before the user requests them. Luckily, these techniques do their work behind the scenes, and do not block any other operations happening on a web page. Some browsers, e.g. Chrome, have some prebrowsing techniques built in.&lt;/p&gt;
&lt;p&gt;They include &lt;code&gt;dns-prefetch&lt;/code&gt;, &lt;code&gt;prefetch&lt;/code&gt;, &lt;code&gt;preconnect&lt;/code&gt;, &lt;code&gt;prerender&lt;/code&gt;, and (a deprecated) &lt;code&gt;subresource&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;None are guaranteed to provide a performance boost in the form of faster render times for users, but there is no harm in including them. They are a great example of progressive enhancement - browsers that are built to use them may provide users a benefit, and browsers that don&#39;t use them won&#39;t disadvantage their users in any way.&lt;/p&gt;
&lt;p&gt;I&#39;ll mention a commonly used one here - &lt;code&gt;dns-prefetch&lt;/code&gt;: My understanding is that this technique allows supporting browsers to open a DNS request ahead of time in the background before something on a page begins rendering. So, for example, &lt;code&gt;dns-prefetch&lt;/code&gt; can open the connection to the CDN containing some images a small amount of time before they actually begin the process of rendering. This can save some milliseconds in render time. So, we can set the URL of our CDN as the value of an &lt;code&gt;href&lt;/code&gt; attribute and add a nice &lt;code&gt;rel&lt;/code&gt; attribute with the relevant prebrowsing value. One more thing to note, all prebrowsing techniques are used within the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; element of an HTML document.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;dns-prefetch&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;//fancyimagecdn.com&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;head&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;See &lt;a href=&quot;https://css-tricks.com/prefetching-preloading-prebrowsing/&quot;&gt;this&lt;/a&gt; CSS tricks article by &lt;a href=&quot;https://www.robinrendle.com/adventures/&quot;&gt;Robin Rendle&lt;/a&gt; for further information.&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>indexOf</title>
      <link href="https://amberwilson.co.uk/learn/indexof/"/>
      <updated>2019-06-12T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/indexof/</id>
      <content type="html">&lt;p&gt;&lt;code&gt;indexOf()&lt;/code&gt; is a handy little JavaScript method that returns the &lt;strong&gt;first&lt;/strong&gt; index (position) of an item within an array or a string. For example:&lt;/p&gt;
&lt;p&gt;Array -&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; catStory &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;The&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Cat&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Is&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Good&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;The&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Cat&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Is&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Fluffy&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; firstCatOccurrence &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Cat&#39;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; firstCatPosition &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; catStory&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;firstCatOccurrence&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;firstCatPosition&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;indexOf()&lt;/code&gt; is case sensitive. Searching for &#39;cat&#39; will return -1.&lt;/li&gt;
&lt;li&gt;Numbers can be searched as well, e.g. [1, 2, 3]&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Or:&lt;/p&gt;
&lt;p&gt;String -&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; catStory &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Pickles the cat slept in twelve different places today&#39;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; catOccurrence &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;cat&#39;&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; catPosition &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; catStory&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;catOccurrence&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;catPosition&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 12&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If an occurrence is not found, &lt;code&gt;-1&lt;/code&gt; will be returned. This is because the &lt;code&gt;indexOf()&lt;/code&gt; method was written a long time ago, and back then it was thought of as sensible to always return a number. Methods such as &lt;code&gt;match()&lt;/code&gt; and &lt;code&gt;includes()&lt;/code&gt; were written later and return &lt;code&gt;null&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; when no occurrence is found. Therefore, to check whether an occurrence exists in your string (or array):&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Kitty Litter&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Lit&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// true&lt;/span&gt;
&lt;span class=&quot;token string&quot;&gt;&#39;Kitty Litter&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;indexOf&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Kittty&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// false&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;See more from MDN about &lt;code&gt;String.prototype.indexOf()&lt;/code&gt;
&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf&quot;&gt;here&lt;/a&gt; and &lt;code&gt;Array.prototype.indexOf()&lt;/code&gt;
&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Array Prototype Methods</title>
      <link href="https://amberwilson.co.uk/learn/array-prototype-methods/"/>
      <updated>2018-07-30T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/array-prototype-methods/</id>
      <content type="html">&lt;p&gt;&lt;code&gt;Array.prototype&lt;/code&gt; methods are super useful for transforming array data and cover a lot of common needs in modern applications! They are a form of higher-order function (HOC), which are functions that take another function as their argument, or return one as a result. A good way to view functions is as values, because then it&#39;s easier to imagine being able to pass them around. For me, they&#39;ve been a great introduction into the world of functional programming. In functional programming, the functions you create are &lt;em&gt;pure&lt;/em&gt;, i.e. they have no side effects, rely on the input you give them, and will always produce the same output given the same input.&lt;/p&gt;
&lt;p&gt;So, I use array methods more and more at work and they are definitely a pleasure to work with! There are quite a lot of them (I think around 50), but there are some more frequently used ones that cover most use cases, such as &lt;code&gt;sort()&lt;/code&gt;, &lt;code&gt;map()&lt;/code&gt;, &lt;code&gt;filter()&lt;/code&gt;, and &lt;code&gt;reduce()&lt;/code&gt;. I was inspired to write about them after reading about &lt;a href=&quot;https://hackernoon.com/a-quick-introduction-to-functional-javascript-7e6fe520e7fa&quot;&gt;functional JavaScript&lt;/a&gt; post by &lt;a href=&quot;https://twitter.com/chalarangelo&quot;&gt;Angelos Chalaris&lt;/a&gt;! Please check out his post because there are &lt;em&gt;great&lt;/em&gt; examples &amp;amp; explanations in there!&lt;/p&gt;
&lt;p&gt;Of course, since I like them so much, I wanted to give an example here. The one I used most at work is &lt;code&gt;map()&lt;/code&gt; but I didn&#39;t choose it because I gave an example of it in &lt;a href=&quot;https://amberwilson.co.uk/learn/arrow-functions&quot;&gt;Day 2&lt;/a&gt; :) As a side note, if you look carefully at the example in Day 2&#39;s lesson, you&#39;ll see how the elements array takes the map function, which in turn takes a function as its input, and returns a value based on the input. Below, I decided to create an example of &lt;code&gt;reduce()&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; initialCatRating &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; accurateCatRating &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; initialCatRating&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;total&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; amount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  total&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;amount &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; total
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

accurateCatRating &lt;span class=&quot;token comment&quot;&gt;// [20, 20, 20]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This example shows one of the &lt;strong&gt;many&lt;/strong&gt; things reduce can do - alter values in an array, and push the altered values into a new array! This means a brand new array is returned, rather than altering the initial array. Let me explain what&#39;s happening:&lt;/p&gt;
&lt;p&gt;There is an &lt;code&gt;initialCatRating&lt;/code&gt; variable, which shows ratings of cats out of ten. In the &lt;code&gt;accurateCatRating&lt;/code&gt; variable, &lt;code&gt;reduce()&lt;/code&gt; is called on &lt;code&gt;initialCatRating&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The first argument in &lt;code&gt;reduce()&lt;/code&gt; is a callback function (see this in &lt;span class=&quot;text__highlight&quot;&gt;pink&lt;/span&gt; above). The callback takes at least two and up to four arguments (&lt;code&gt;accumulator, currentValue, currentIndex, array&lt;/code&gt;). The above example has taken two - &lt;code&gt;total&lt;/code&gt; and &lt;code&gt;amount&lt;/code&gt;, which are actually &lt;code&gt;accumulator&lt;/code&gt; and &lt;code&gt;currentValue&lt;/code&gt;. Naming doesn&#39;t matter here, but order does.&lt;/p&gt;
&lt;p&gt;The second argument in &lt;code&gt;reduce()&lt;/code&gt; is &lt;code&gt;initialValue&lt;/code&gt;, which is optional. In the above example, &lt;code&gt;initialValue&lt;/code&gt; is an empty array. The callback only operates on every element in an &lt;em&gt;array&lt;/em&gt; when &lt;code&gt;initialValue&lt;/code&gt; is present, so for the above example it is not optional.&lt;/p&gt;
&lt;p&gt;Putting the callback and &lt;code&gt;initialValue&lt;/code&gt; together allows &lt;code&gt;reduce()&lt;/code&gt; to take each element in the given array and operate on it, then push the returned values (using &lt;code&gt;push()&lt;/code&gt; - another array method) into a new array.&lt;/p&gt;
&lt;p&gt;Of course, to make it re-usable, you can extract the callback function from the above example into something like:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token function-variable function&quot;&gt;doubleMyValue&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;total&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; amount&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  total&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;amount &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; total
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, it can be put straight into &lt;code&gt;reduce()&lt;/code&gt; (as an argument), to read:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; initialCatRating &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; accurateCatRating &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; initialCatRating&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;reduce&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;doubleMyValue&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

accurateCatRating &lt;span class=&quot;token comment&quot;&gt;// [20, 20, 20]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;reduce()&lt;/code&gt; callback above is actually not a pure function, because it modifies one of its parameters. To keep &lt;code&gt;reduce()&lt;/code&gt; pure/functional, the callback can only take primitive values. See the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce&quot;&gt;MDN Array.reduce&lt;/a&gt; article for examples. And see some more examples on &lt;a href=&quot;https://medium.freecodecamp.org/reduce-f47a7da511a9&quot;&gt;Array.reduce&lt;/a&gt;. Try some &lt;code&gt;Array.prototype&lt;/code&gt; methods out in your browser console! :)&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Ternary Operator</title>
      <link href="https://amberwilson.co.uk/learn/ternary-operator/"/>
      <updated>2018-07-23T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/ternary-operator/</id>
      <content type="html">&lt;p&gt;This is one of my favourite things in JavaScript. Not only is it simple and easy to use but it&#39;s also applicable to lots of situations &lt;strong&gt;and&lt;/strong&gt; it can replace more verbose syntax (like &lt;code&gt;if&lt;/code&gt; statements). It looks something like this:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; hoursOfSleep &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;5&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; timeForSleep &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;
  hoursOfSleep &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Yup, no more phone for you&#39;&lt;/span&gt;
    &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Ah nah, a few more minutes of phone time won&#39;t hurt&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice the &lt;strong&gt;?&lt;/strong&gt; and the &lt;strong&gt;:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;These are the important parts.&lt;/p&gt;
&lt;p&gt;If the condition (in this case &lt;code&gt;hoursOfSleep&lt;/code&gt;) in front of the question mark evaluates to true, the value of the first expression before the colon is returned. If the condition in front of the question mark evaluates to false, the value of the second expression after the colon is returned. As you can see, if you have had less than 8 hours of sleep, you shouldn&#39;t be using your phone.&lt;/p&gt;
&lt;p&gt;Ternary operators are really flexible and can be used in a number of ways. You can stack them together:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; catsRule &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; dogsDrool &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; catDog &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; catsRule &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dogsDrool &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Let&#39;s all live in harmony&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Both cats and dogs drool&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dogsDrool &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Dogs are cool, nearly as cool as cats&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Dogs and cats can be friends&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This outputs &lt;code&gt;&amp;quot;Both cats and dogs drool&amp;quot;&lt;/code&gt;, and it&#39;s also total nonsense but I hope you had fun staring at it and trying to figure it out. You don&#39;t even need to use the parentheses, and can also use multiple statements separated by commas. You can return statements in functions. You can use them in place of bulky &lt;code&gt;if/else&lt;/code&gt; statements with much nicer-to-read code. The question mark means &lt;code&gt;if&lt;/code&gt; and the colon means &lt;code&gt;else&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I use ternary operators at work all the time. I hope you enjoy them as much as I do. Check out the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator&quot;&gt;MDN&lt;/a&gt; page for some examples. This &lt;a href=&quot;https://scotch.io/tutorials/understand-the-javascript-ternary-operator-like-abc&quot;&gt;post&lt;/a&gt; is lovely too.&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Object Literals</title>
      <link href="https://amberwilson.co.uk/learn/object-literals/"/>
      <updated>2018-07-15T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/object-literals/</id>
      <content type="html">&lt;p&gt;I didn&#39;t learn about these at work but rather from a &lt;a href=&quot;https://www.youtube.com/watch?v=1DMolJ2FrNY&quot;&gt;video&lt;/a&gt; on the JavaScript reduce function by the wonderful &lt;a href=&quot;https://twitter.com/mpjme&quot;&gt;MPJ&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Object literals are a data structure that can be used in JavaScript. I really like seeing how data can be organised and object literals do this really nice and tidily. Here&#39;s an example:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; cat &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;myCat&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Tabby&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token literal-property property&quot;&gt;getCat&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;catTypes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Siamese&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above code is an alteration of the MDN &lt;a href=&quot;https://developer.mozilla.org/bm/docs/Web/JavaScript/Guide/Grammar_and_types#Object_literals&quot;&gt;example&lt;/a&gt;. I found MDN&#39;s explanation of object literals a little mechanical (compared to other resources I found), but it does give quite a clear portrayal of how flexible object literals can be. For instance, the typical combination of a key (&lt;code&gt;myCat&lt;/code&gt;), value (&lt;code&gt;Tabby&lt;/code&gt;) pair can be accessed and used in other places in your code, without these values polluting the global scope*. You can use the &lt;code&gt;catTypes&lt;/code&gt; function like so:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;catTypes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;type &lt;span class=&quot;token operator&quot;&gt;!==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Siamese&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; type
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Many &#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; type &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39; cats have blue eyes.&#39;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;

console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;cat&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;getCat&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// Many Siamese cats have blue eyes.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If this was not exciting enough, there are many other data types (not only functions) that can be organised using object literals - e.g. array literals (see an example of this in MPJ&#39;s video), nested object literals, numbers, any string, etc.&lt;/p&gt;
&lt;p&gt;My friend &lt;a href=&quot;https://qubyte.codes/&quot;&gt;Mark&lt;/a&gt; also informed me that an object can contain itself (which is not recommend because it breaks JSON.stringify)!&lt;/p&gt;
&lt;p&gt;Of course as with any programming language, there are rules. Some of these are that a colon separates the key from the value, a comma separates key-value pairs, there shouldn&#39;t be a comma after the last value-pair (well, it&#39;s fine to have a dangling comma, but many style guides don&#39;t want you to do it), etc.&lt;/p&gt;
&lt;p&gt;For more rules and when to use, check out &lt;a href=&quot;http://www.dyn-web.com/tutorials/object-literal/#f2&quot;&gt;this&lt;/a&gt; nice post, and the MDN page.&lt;/p&gt;
&lt;p&gt;I haven&#39;t had much of a chance to use object literals in the wild yet, but I hope to soon. After I have, I hope to write an updated post that describes my new insights.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An object (literal) can be used like a namespace to avoid polluting the global object, but there&#39;s still the reference of the object attached to global. If you want to completely eliminate variables polluting the global object as fields, then IIFEs are for you. Some modules are also isolated from global. So, object literals limit pollution through namespacing, but do not entirely eliminate it. (Thanks, &lt;a href=&quot;https://qubyte.codes/&quot;&gt;Mark&lt;/a&gt;, for the information).&lt;/li&gt;
&lt;/ul&gt;
</content>
    </entry>
    
    <entry>
      <title>Testing</title>
      <link href="https://amberwilson.co.uk/learn/testing/"/>
      <updated>2018-07-12T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/testing/</id>
      <content type="html">&lt;p&gt;Today at work, we talked about test automation. One of the developers mentioned this quote:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We cannot rely on mass inspection to improve quality, though there are times when 100 percent inspection is necessary. As Harold S. Dodge said many years ago, ‘You cannot inspect quality into a product.’ The quality is there or it isn’t by the time it’s inspected. - William E. Deming in &lt;em&gt;Out of the Crisis&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Therefore we cannot rely on creating features in a hurry, throwing them over the fence and then expecting our applications to work well and without bugs. To instil quality from the start of a feature, there should be tests for it.&lt;/p&gt;
&lt;p&gt;Automated testing helps with this. Pre-commit hooks can be used when deploying builds so that errors are caught and addressed early. Unit tests can be run using pre-commit hooks - see my post on unit tests &lt;a href=&quot;https://amberwilson.co.uk/blog/unit-tests/&quot;&gt;here&lt;/a&gt;. However, there is a fine line between having too many automated tests, e.g. end-to-end tests that take too long to run with each build, and not having enough. Some companies run quicker unit tests on each build, and then run end-to-end tests as a nightly build.&lt;/p&gt;
&lt;p&gt;Please see the image below for one of many examples of the testing pyramid if you are confused when I mention unit tests or end-to-end (UI) tests:&lt;/p&gt;
&lt;a href=&quot;http://blog.xebia.com/its-2017-test-automation-is-not-optional-when-building-mobile-apps/&quot;&gt;
    &lt;img src=&quot;https://amberwilson.co.uk/learn/img/test-pyramid.png&quot; alt=&quot;The Testing Pyramid&quot; /&gt;
&lt;/a&gt;
&lt;p&gt;Manual testing is important too. It is usually done by QA engineers, and helps reveal edge cases that automated tests do not catch. As one developer at my work said, these tests are like the cherry on top of the testing pyramid.&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Emmet</title>
      <link href="https://amberwilson.co.uk/learn/emmet/"/>
      <updated>2018-07-02T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/emmet/</id>
      <content type="html">&lt;p&gt;Emmet provides a really useful way to make developing easier. It improves the &lt;strong&gt;developer experience&lt;/strong&gt;™. I only discovered it recently but love it already. It originated as &lt;a href=&quot;https://www.smashingmagazine.com/2009/11/zen-coding-a-new-way-to-write-html-code/&quot;&gt;Zen Coding&lt;/a&gt; about ten years ago. There are a few uses (see official &lt;a href=&quot;https://docs.emmet.io/&quot;&gt;docs&lt;/a&gt;), but I&#39;ll focus on the amazing &lt;em&gt;abbreviation and snippet expansion&lt;/em&gt; feature.&lt;/p&gt;
&lt;p&gt;In your HTML, say you need 100 divs. And each should have a class of teddybear. Typing these out by hand might be boring. With Emmet, you can write &lt;code&gt;div*100.teddybear&lt;/code&gt; (then press &#39;tab&#39;). Or if you need each class to be item1, item2, etc. then you can write &lt;code&gt;div.item$*3&lt;/code&gt;. There are also HTML elements that get handily created with relevent attributes - try typing &lt;code&gt;a&lt;/code&gt; or &lt;code&gt;img&lt;/code&gt;. See one of the original articles on Emmet &lt;a href=&quot;https://www.smashingmagazine.com/2009/11/zen-coding-a-new-way-to-write-html-code/&quot;&gt;here&lt;/a&gt; for more examples. You can download it or check if it comes built-in with your text editor of choice - I use VSCode and found Emmet was ready for use!&lt;/p&gt;
&lt;p&gt;Emmet also features CSS selector expansion which allows you to type abbreviated selectors that are expanded when you press &#39;tab&#39;. It can also automatically add vendor prefixes for you. Try and see how many abbreviations you can guess &lt;a href=&quot;https://docs.emmet.io/css-abbreviations/fuzzy-search/&quot;&gt;here&lt;/a&gt; ;)&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Strings</title>
      <link href="https://amberwilson.co.uk/learn/strings/"/>
      <updated>2018-06-18T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/strings/</id>
      <content type="html">&lt;ul&gt;
&lt;li&gt;A sequence containing some letters, numbers or symbols.&lt;/li&gt;
&lt;li&gt;Have available methods and properties.&lt;/li&gt;
&lt;li&gt;Can be stored in variables.&lt;/li&gt;
&lt;li&gt;Sit between either single quotes (&lt;code&gt;&#39; &#39;&lt;/code&gt;), double quotes (&lt;code&gt;&amp;quot; &amp;quot;&lt;/code&gt;), or backticks (&lt;code&gt;``&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Can be concatenated (stuck together) with the &lt;code&gt;+&lt;/code&gt; operator, or with backticks (template strings) in ES6.&lt;/li&gt;
&lt;li&gt;Template strings, or template literals, can take any valid JavaScript expression, allowing dynamic strings.&lt;/li&gt;
&lt;li&gt;Can contain special characters, such as quotation marks, as long as they are escaped - e.g. &lt;code&gt;&amp;quot;She&#39;&#92;ll be coming &#39;&#92;round the mountain when she comes&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;There&#39;s no need to escape dissimilar quote marks. For example: &amp;quot;This &#39;is&#39; fine&amp;quot;. This is probably why we tend to favour double quotes in HTML attribute values, and singles in JS (since it allows you to create some innerHTML without the need for escaping).&lt;/li&gt;
&lt;li&gt;When using template literals, you don&#39;t need to escape &lt;code&gt;&#39;&lt;/code&gt; or &lt;code&gt;&amp;quot;&lt;/code&gt; ... and &lt;code&gt;this` `&amp;quot;is&amp;quot;` `&#39;also&#39;` `fine&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Is either a &lt;em&gt;string primitive&lt;/em&gt; - immutable and more common, e.g. &lt;code&gt;const stringPrimitive = &amp;quot;Hello, I am a string.&amp;quot;;&lt;/code&gt; .&lt;/li&gt;
&lt;li&gt;Or a &lt;em&gt;string object&lt;/em&gt; - &lt;code&gt;const stringObject = new String(&amp;quot;Hello, I am a string.&amp;quot;);&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;typeof&lt;/code&gt; operator is used to determine if a string&#39;s type is &lt;em&gt;string&lt;/em&gt; or &lt;em&gt;object&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Each character is indexed and can be accessed by an index number using square bracket notation (e.g. &amp;quot;Hello World&amp;quot; - &lt;code&gt;myString[0]&lt;/code&gt; outputs &amp;quot;H&amp;quot;).&lt;/li&gt;
&lt;li&gt;Similar methods to the one above include: &lt;code&gt;charAt()&lt;/code&gt;, &lt;code&gt;indexOf()&lt;/code&gt;, &lt;code&gt;lastIndexOf()&lt;/code&gt;, &lt;code&gt;slice()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Other common methods and properties are: &lt;code&gt;length&lt;/code&gt;, &lt;code&gt;toUpperCase()&lt;/code&gt;, &lt;code&gt;toLowerCase()&lt;/code&gt;, &lt;code&gt;split()&lt;/code&gt;, &lt;code&gt;trim()&lt;/code&gt;, &lt;code&gt;replace()&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This list is meant as a quick and basic introduction to the magical world of JavaScript strings. If there&#39;s something you&#39;d like me to add, let me know!&lt;/p&gt;
&lt;p&gt;Many thanks to my good friend &lt;a href=&quot;https://twitter.com/qubyte&quot;&gt;Mark&lt;/a&gt; for suggesting additions :)&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Readable Code</title>
      <link href="https://amberwilson.co.uk/learn/readable-code/"/>
      <updated>2018-06-05T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/readable-code/</id>
      <content type="html">&lt;p&gt;There are so many books, articles, and videos about how to make code readable, so I&#39;ll keep this short and from my perspective (as a new developer who works mainly with JavaScript).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Code style&lt;/strong&gt; of your project. This is specific to each project and covers things like indentation, levels of nesting, naming, spacing etc. There are some nice tools to help with this - for example &lt;em&gt;ESLint&lt;/em&gt; that you can configure to auto-format your code to your specified style upon file save.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Structure&lt;/strong&gt;. This is about how you organise your code and files in a project. I have been taught the benefit of abstracting and modularising code, making it easier to tell what each part does and easier to test. In React, I&#39;ve been writing components that are either presentational (how things look) or containers (how things work). Between different projects and programming languages, there are many, many ways to structure code well, and opinions tend to differ.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Commenting&lt;/strong&gt;. There are three ways I&#39;ve been doing this - either in my CSS, or in one of two ways (single-line with &lt;code&gt;//&lt;/code&gt; or the &lt;a href=&quot;http://usejsdoc.org/index.html&quot;&gt;JSDoc&lt;/a&gt; way) in my JS. The most important way to comment CSS is when &lt;em&gt;magic numbers&lt;/em&gt;, i.e. seemingly random numbers that don&#39;t use pre-defined mixins or seem to relate to the rest of the code, are present. Leaving a note about these numbers can help other developers (or yourself a few months later) understand why the CSS is written that way. An important thing to remember when commenting JS code is that comments should state what the expected results of the code (e.g. a function) is, and not a description of what the code is doing.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Naming&lt;/strong&gt;. This is well-known as one of the hardest things in programming. But it pays off big time. It helps developers get as close a possible to the coveted &lt;em&gt;self-documenting code&lt;/em&gt; that doesn&#39;t need any comments (although I think no comments at all is probably a bad thing). I feel some developers keep function and variable names short in order to make their code look cleaner and keep file sizes small. However, on my latest project at work, without some of the really long and descriptive naming going on, I&#39;d have a much harder time understanding the complex codebase.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are the four areas around readable code that popped into my mind. There are definitely more, and there are &lt;em&gt;so&lt;/em&gt; many resources on this. Go check &#39;em out, and discuss them with people! I know I&#39;ll continue to do both those things for a long time to come.&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Debugging</title>
      <link href="https://amberwilson.co.uk/learn/debugging/"/>
      <updated>2018-06-03T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/debugging/</id>
      <content type="html">&lt;p&gt;Recently at work, I&#39;ve watched other developers use &lt;code&gt;console.log&lt;/code&gt; a lot in code to find desired values given by certain functions. I am often still confused where to put &lt;code&gt;console.log&lt;/code&gt;, and it is definitely not the only way to debug, so I&#39;ve also begun to use the developer tools JavaScript debugger in Firefox and Chrome. These tools allow you to pause the execution of your code, and walk through it to help you find bugs.&lt;/p&gt;
&lt;p&gt;The debugger can do a lot, and it&#39;d take a much longer post to walk through this tool&#39;s UI, so I&#39;ll mention four of the most commonly used debugging methods here.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Step over code&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Steps over a function that doesn&#39;t contain a bug and runs its code&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Step into code&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Steps inside a function and allows you to run each part separately&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Step out of code&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Steps out of a function you are inside, and runs its code&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Resume execution of code&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Debugging is something developers have to be really good at. So don&#39;t be scared to do it! Or, be scared but do it anyway, you&#39;ll get better :)&lt;/p&gt;
&lt;p&gt;Check out the docs on the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Tools/Debugger&quot;&gt;Firefox&lt;/a&gt; debugger and the &lt;a href=&quot;https://developers.google.com/web/tools/chrome-devtools/javascript/reference#breakpoints&quot;&gt;Chrome&lt;/a&gt; debugger. Lots of great info there to help you get started. Also check out &lt;a href=&quot;https://peterlyons.com/js-debug&quot;&gt;this article&lt;/a&gt; from Peter Lyons. He explains debugging of both front-end and back-end JavaScript code.&lt;/p&gt;
&lt;p&gt;Also, check &lt;a href=&quot;https://daverupert.com/2018/05/my-struggle-with-testing-code/&quot;&gt;this&lt;/a&gt; out - an honest post about how even experienced devs find it hard to debug.&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>CSS Layout</title>
      <link href="https://amberwilson.co.uk/learn/css-layout/"/>
      <updated>2018-06-28T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/css-layout/</id>
      <content type="html">&lt;p&gt;CSS layout is something that amazes and confuses me at the same time. There seem to be so many approaches (e.g. floats, flexbox, grid), and so many frameworks (way too many to mention). The paradox of choice seems to apply here.&lt;/p&gt;
&lt;p&gt;I love hearing from people about CSS layout, and I was lucky to hear &lt;a href=&quot;http://www.miriamsuzanne.com/&quot;&gt;Miriam Suzanne&lt;/a&gt; talk about it at &lt;a href=&quot;https://beyondtellerrand.com/events/duesseldorf-2018/speakers&quot;&gt;Beyond Tellerrand&lt;/a&gt; (check out the awesome layout on her site). The message she gave was to use CSS grid, and provide fallbacks for browsers that aren&#39;t grid-compatible. She reasons that as grid makes layouts so easy (and naturally responsive), that there is time to re-create fallback layouts, which allows more creative control.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;Often I allow fallback layouts to be much simpler. CSS Grid has power to create layouts that have
no *exact* fallback. Since grid makes many layouts easier, I have extra time to do both. Similar
time spent, more creative control.&lt;br /&gt;&lt;br /&gt;Your mileage will depend on your constraints.&lt;/p&gt;&amp;mdash;
Miriam Suzanne (@mirisuzanne) &lt;a href=&quot;https://twitter.com/mirisuzanne/status/993813309441880064?ref_src=twsrc%5Etfw&quot;&gt;May 8, 2018&lt;/a&gt;&lt;/blockquote&gt;
&lt;p&gt;One thing I really like about CSS layouts is that they aren&#39;t designed to be used in isolation. On the contrary, you can mix and match them. A grid item can become a flex container, and a flex item can become a grid. You can even use floats with flexbox and grid.&lt;/p&gt;
&lt;p&gt;I am half-way through Wes Bos&#39;s &lt;a href=&quot;https://cssgrid.io/&quot;&gt;CSS grid&lt;/a&gt; course and already have ideas I am excited to make come to life using grid. There are looots of great posts and articles out there by people who have had tonnes of fun and learned loads by using grid. I really recommend finding some and making some stuff!&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>JSON-LD</title>
      <link href="https://amberwilson.co.uk/learn/json-ld/"/>
      <updated>2018-05-29T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/json-ld/</id>
      <content type="html">&lt;p&gt;JSON, or JavaScript Object Notation, is a simple language that represents objects on the Web and facilitates data exchange. LD, or Linked Data, allows for the expression of critical data on a site, and for it to be shared across sites. I first heard of it at &lt;a href=&quot;https://beyondtellerrand.com/events/duesseldorf-2018/speakers&quot;&gt;Beyond Tellerrand&lt;/a&gt; in Düsseldorf on May 7th, during a talk about web annotations by &lt;a href=&quot;https://lyza.com/&quot;&gt;Lyza Danger Gardner&lt;/a&gt;. JSON-LD allows expressions of linked data in JavaScript. It&#39;s like grammar for describing strutured data. It can be thought of as JSON, but with added semantics. And it can be easily implemented into existing JSON structures. Here&#39;s some example JSON:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token string-property property&quot;&gt;&quot;name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Amber Wilson&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string-property property&quot;&gt;&quot;homepage&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;https://amberwilson.co.uk&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string-property property&quot;&gt;&quot;picture&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &quot;https&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;twitter&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;com&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;account&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;
    profil_image&lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt;ambrwlsn90&quot;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here is similar information in JSON-LD format:&lt;/p&gt;
&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token string-property property&quot;&gt;&quot;@context&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;token string-property property&quot;&gt;&quot;xsd&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;http://www.w3c.org/2001/XMLSchema#&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token string-property property&quot;&gt;&quot;foaf&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;http://xmlns.com/foaf/0.1/&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string-property property&quot;&gt;&quot;@id&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;http://me.amberwilson.co.uk&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string-property property&quot;&gt;&quot;@type&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;foaf:Person&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string-property property&quot;&gt;&quot;foaf:name&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Amber Wilson&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Above, we see that &lt;code&gt;context&lt;/code&gt; can be added to data. &lt;code&gt;foaf&lt;/code&gt; stands for &amp;quot;friend of a friend&amp;quot; (see &lt;a href=&quot;http://www.foaf-project.org/&quot;&gt;here&lt;/a&gt;), which deals with people-related terms. &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;type&lt;/code&gt;, like &lt;code&gt;context&lt;/code&gt;, assist in making our data shareable and semantic.&lt;/p&gt;
&lt;p&gt;The concept of JSON-LD is simple, but using it can take getting used to. For more in-depth information, see &lt;a href=&quot;https://json-ld.org/primer/latest/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Flux</title>
      <link href="https://amberwilson.co.uk/learn/flux/"/>
      <updated>2018-05-25T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/flux/</id>
      <content type="html">&lt;p&gt;Recently, I began to write React at work and I&#39;ve been doing okay with presentational components, but much less so with business logic (I hear ya &lt;a href=&quot;http://bradfrost.com/blog/post/my-struggle-to-learn-react/&quot;&gt;Brad Frost&lt;/a&gt;). I&#39;ve heard that improving my ES6 will really help, so you&#39;ll see more little lessons on it, but I also want to touch on how to manage dynamic state. Despite the popularity of Redux, one of my developer friends recommended covering Flux.&lt;/p&gt;
&lt;p&gt;Flux is an application architecture for React (that can also be used elsewhere) utilizing a unidirectional data flow. In essence, it is an observer pattern that offers one-way data binding. Very useful when you need to keep lots of components in sync.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;action -&amp;gt; dispatcher -&amp;gt; store -&amp;gt; view&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;action&lt;/strong&gt; creator formats messages (what the user does) from the UI&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;dispatcher&lt;/strong&gt; takes the formatted messages and synchronously sends them to different stores&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;store&lt;/strong&gt; holds all state logic and changes it by deciding what actions it wants to pay attention to&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;view&lt;/strong&gt; takes changes from the store and updates the UI&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Please look at Lin Clark&#39;s great &lt;a href=&quot;https://code-cartoons.com/a-cartoon-guide-to-flux-6157355ab207&quot;&gt;cartoon guide&lt;/a&gt; for more details. For a more code-heavy example, see &lt;a href=&quot;https://blog.andrewray.me/flux-for-stupid-people/&quot;&gt;here&lt;/a&gt;. I feel like the best way to learn about Flux is to build things in tandem with reading about it (and finding nice developers who can guide you)!&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>This</title>
      <link href="https://amberwilson.co.uk/learn/this/"/>
      <updated>2018-05-23T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/this/</id>
      <content type="html">&lt;p&gt;The &lt;code&gt;this&lt;/code&gt; keyword is found in various programming languages, and behaves a certain way in JavaScript. Apparently even experienced developers get confused by it.&lt;/p&gt;
&lt;p&gt;See this &lt;a href=&quot;https://codepen.io/ambrwlsn90/pen/ELEmxw?editors=1111&quot;&gt;codepen&lt;/a&gt; for some example code. It showcases one of the six ways &lt;code&gt;this&lt;/code&gt; is used in JavaScript - thanks to what I learned from Zell Liew&#39;s great &lt;a href=&quot;https://zellwk.com/blog/this/&quot;&gt;blog post&lt;/a&gt;. I really recommend this post for beginners - you can try the examples in your console! In short, &lt;code&gt;this&lt;/code&gt; can be used globally, in object constructions, object methods, simple functions, arrow functions, and event listeners. See the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this&quot;&gt;MDN docs&lt;/a&gt; for more code-heavy examples.&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Pseudo Selectors</title>
      <link href="https://amberwilson.co.uk/learn/pseudo-selectors/"/>
      <updated>2018-05-21T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/pseudo-selectors/</id>
      <content type="html">&lt;p&gt;I only just found out that &lt;code&gt;::before&lt;/code&gt; (&lt;code&gt;:before&lt;/code&gt;) and &lt;code&gt;::after&lt;/code&gt; (&lt;code&gt;:after&lt;/code&gt;) are pseudo elements, which are different from pseudo classes. Both of these are grouped under pseudo selectors. I like this quote from MDN ~&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Even the most skilled web developers are still amazed by what&#39;s possible using selectors.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;pseudo selectors are only two types of selectors. The others are: simple selectors, attribute selectors, multiple selectors and combinators. All of these help us to target and style HTML elements.&lt;/p&gt;
&lt;p&gt;So, pseudo selectors include both pseudo elements and pseudo classes. They are added to the end of other selectors, and don&#39;t apply to whole elements, only parts of them.&lt;/p&gt;
&lt;p&gt;The pseudo classes (e.g. &lt;code&gt;:hover&lt;/code&gt;, &lt;code&gt;:focus&lt;/code&gt;, and &lt;code&gt;:nth-of-type()&lt;/code&gt; - plus 38 others) style elements in a &lt;em&gt;certain state&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The pseudo elements (e.g. &lt;code&gt;::after&lt;/code&gt;, &lt;code&gt;::before&lt;/code&gt;, and &lt;code&gt;::first-letter&lt;/code&gt; - plus 3 others, not including experimental ones) apparently need &lt;code&gt;::&lt;/code&gt; rather than &lt;code&gt;:&lt;/code&gt;, although I&#39;ve used them with only one. These don&#39;t depend on the state of an element.&lt;/p&gt;
&lt;p&gt;See this &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Pseudo-classes_and_pseudo-elements&quot;&gt;MDN&lt;/a&gt; page for great examples and to use their awesome active learning playground (I did and it was great for learning)!&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>Arrow Functions</title>
      <link href="https://amberwilson.co.uk/learn/arrow-functions/"/>
      <updated>2018-05-15T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/arrow-functions/</id>
      <content type="html">&lt;p&gt;Also known as a fat arrow, &lt;code&gt;=&amp;gt;&lt;/code&gt;. This ES6 feature is a fat topic, so I&#39;ll concentrate on one aspect today.&lt;/p&gt;
&lt;pre class=&quot;language-jsx&quot;&gt;&lt;code class=&quot;language-jsx&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; elements &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Hydrogen&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Helium&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Lithium&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;Beryllium&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

elements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;element&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  elements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;element&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;elements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;element&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; element&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;elements&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; length &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Above is an altered version of the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions&quot;&gt;MDN&lt;/a&gt; JavaScript Demo, where you will find a wealth of information on what fat arrows can do for you. The first function in the list is written without fat arrows. The last three functions are variations of the first function, showing how fat arrows can be used to write shorter function expressions, and therefore less code. You will need a code compiler like &lt;a href=&quot;https://babeljs.io/&quot;&gt;Babel&lt;/a&gt; to compile fat arrows into ES5 syntax so older browsers can use your JavaScript.&lt;/p&gt;
&lt;p&gt;There are a &lt;em&gt;lot&lt;/em&gt; of resources that try explaining this syntax. Try Wes Bos&#39;s &lt;a href=&quot;https://wesbos.com/arrow-functions/&quot;&gt;introduction&lt;/a&gt; for a start. This is complicated subject matter, though, so I suggest searching around for different posts, reading a few and finding ones that make most sense to you.&lt;/p&gt;
</content>
    </entry>
    
    <entry>
      <title>BEM</title>
      <link href="https://amberwilson.co.uk/learn/BEM/"/>
      <updated>2018-05-02T00:00:00+00:00</updated>
      <id>https://amberwilson.co.uk/learn/BEM/</id>
      <content type="html">&lt;p&gt;I keep getting tripped up at work by forgetting to write modular CSS classes. There are so many benefits to a robust CSS architecture that I really want to get it right. BEM is a methodology to achieve this. &lt;code&gt;Block&lt;/code&gt;, &lt;code&gt;Element&lt;/code&gt; and &lt;code&gt;Modifier&lt;/code&gt;. A &lt;code&gt;Block&lt;/code&gt; is a component or feature than can stand alone and is not dependent on any other code. It can be re-used anywhere. Next, an &lt;code&gt;Element&lt;/code&gt;. This is always part of a &lt;code&gt;Block&lt;/code&gt; and has no meaning on its own. Lastly, there is the &lt;code&gt;Modifier&lt;/code&gt;. This changes the behaviour and/or appearance of a &lt;code&gt;Block&lt;/code&gt; or &lt;code&gt;Element&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;.button&lt;/code&gt;&lt;/strong&gt; is a block.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;.button__label&lt;/code&gt;&lt;/strong&gt; is an element.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;.button--confirm&lt;/code&gt;&lt;/strong&gt; is a modifier.&lt;/p&gt;
&lt;p&gt;See resources &lt;a href=&quot;http://getbem.com/introduction/&quot;&gt;here&lt;/a&gt; and &lt;a href=&quot;https://zellwk.com/blog/css-architecture-1/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
</content>
    </entry>
</feed>