<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kai</title>
    <description>The latest articles on DEV Community by Kai (@kais_blog).</description>
    <link>https://dev.to/kais_blog</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F533699%2F39a22e79-b568-4664-b9bf-f5a986eb92a8.png</url>
      <title>DEV Community: Kai</title>
      <link>https://dev.to/kais_blog</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kais_blog"/>
    <language>en</language>
    <item>
      <title>5 Reasons Why You Should Never, Ever Write Tests</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Mon, 30 Aug 2021 11:57:33 +0000</pubDate>
      <link>https://dev.to/kais_blog/5-reasons-why-you-should-never-ever-write-tests-3ebf</link>
      <guid>https://dev.to/kais_blog/5-reasons-why-you-should-never-ever-write-tests-3ebf</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/reasons-why-you-should-never-ever-write-tests"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;As a software developer, there is one topic that always leads to controversial discussions. Should one write tests or not? While there are always questionable experts who argue FOR writing tests, I have the definitive answer. Don't.&lt;/p&gt;

&lt;p&gt;Many terrible things happen once you start testing your code. So I prepared a small, incomplete list to show you why you should never, ever, write tests:&lt;/p&gt;




&lt;h2&gt;
  
  
  You would start to question your code
&lt;/h2&gt;

&lt;p&gt;What audacity. If you wrote tests, which of course you won't, your code would be questioned. Does it work as expected? Of course it does. Besides, there's no point in catching catastrophic bugs early, after all, they only ever happen in someone else's projects.&lt;/p&gt;




&lt;h2&gt;
  
  
  Your code would be clearly defined and well designed
&lt;/h2&gt;

&lt;p&gt;You're not an art student, are you? Then what do you care about design? If you ever test parts of your code, you would be forced to clearly define what the code is responsible for. So you would focus on what is essential. With that you take away the possibility to sneak in code that nobody needs and nobody uses.&lt;/p&gt;




&lt;h2&gt;
  
  
  You would have to write less code
&lt;/h2&gt;

&lt;p&gt;Testing can lead you to write less code. After all, you only ever implement so far that the tests pass. And less code means fewer lines of code. Who can brag about having worked on gigantic projects when there aren't that many lines of code? Besides, we're still in the 2000s, somehow, and we're billed on the basis of lines of code (LOC). Never reduce the lines of code. Ever.&lt;/p&gt;




&lt;h2&gt;
  
  
  You would save countless hours that you could normally waste on debugging or maintenance
&lt;/h2&gt;

&lt;p&gt;This point is really critical. If, strangely enough, you are not paid by lines of code, then at least by the hour. With testing you would save many hours. How awful is the idea that you suddenly have time for other things and on top of that the certainty that the code behaves as expected. Scary.&lt;/p&gt;




&lt;h2&gt;
  
  
  You would enable others to understand your code and collaborate with you
&lt;/h2&gt;

&lt;p&gt;I don't really need to write that much about it. Why would you even want to do that? With tests, your code is suddenly documented and much easier to refactor. Not good. If you are no longer the only one who can work on a project, then you will definitely be replaced immediately.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;There you have it. My list of reasons why you should definitely not write tests. In summary, tests have only drawbacks and you should definitely &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;follow me on Twitter&lt;/a&gt; if you want to learn even more about how to avoid being a good software developer.&lt;/p&gt;

&lt;p&gt;If you want to convince other software developers why they shouldn't write tests, feel free to share this post with them.&lt;/p&gt;

&lt;p&gt;Seriously though, write tests.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/reasons-why-you-should-never-ever-write-tests"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>webdev</category>
      <category>testing</category>
    </item>
    <item>
      <title>The Difference Between i++ and ++i (Postfix vs. Prefix)</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Wed, 24 Feb 2021 14:37:35 +0000</pubDate>
      <link>https://dev.to/kais_blog/the-difference-between-i-and-i-postfix-vs-prefix-4ape</link>
      <guid>https://dev.to/kais_blog/the-difference-between-i-and-i-postfix-vs-prefix-4ape</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/the-difference-between-i-and-i-postfix-vs-prefix"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;




&lt;p&gt;JavaScript (and many other languages) support the &lt;em&gt;postfix&lt;/em&gt; and the &lt;em&gt;prefix increment operator&lt;/em&gt; (&lt;code&gt;++&lt;/code&gt;). You have probably seen and used it before.&lt;/p&gt;

&lt;p&gt;Often it's used like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case it's almost equivalent to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But, what do you think? Is there a difference between&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;Well, yes. The first example uses the &lt;em&gt;postfix increment operator&lt;/em&gt; (&lt;code&gt;i++&lt;/code&gt;). The second example uses the &lt;em&gt;prefix increment operator&lt;/em&gt; (&lt;code&gt;++i&lt;/code&gt;). At first, it seems like there's no difference. However, it's important to understand what is going on here:&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;postfix increment operator&lt;/em&gt; increments the value and returns the value &lt;strong&gt;before&lt;/strong&gt; the increment.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;prefix increment operator&lt;/em&gt; increments the value and returns the value &lt;strong&gt;after&lt;/strong&gt; the increment. &lt;/p&gt;

&lt;p&gt;Let's take a look at our two examples again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// postfix increment&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt; &lt;span class="c1"&gt;// { i: 4, j: 3 }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// prefix increment&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt; &lt;span class="c1"&gt;// { i: 4, j: 4 }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spotted the difference? The value of &lt;code&gt;j&lt;/code&gt; differs. Therefore, it is important to know this small difference between &lt;em&gt;postfix&lt;/em&gt; and &lt;em&gt;prefix&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;By the way, the same applies to the &lt;em&gt;postfix decrement&lt;/em&gt; and &lt;em&gt;prefix decrement operator&lt;/em&gt; (&lt;code&gt;--&lt;/code&gt;). The only difference is, that instead of &lt;em&gt;incrementing&lt;/em&gt; we are &lt;em&gt;decrementing&lt;/em&gt; the value.&lt;/p&gt;

&lt;p&gt;That's all there is to say. I hope I made the difference a bit clearer. See you soon!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/the-difference-between-i-and-i-postfix-vs-prefix"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to Generate a Secure Random Number in Node.js</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Wed, 17 Feb 2021 14:31:45 +0000</pubDate>
      <link>https://dev.to/kais_blog/how-to-generate-a-secure-random-number-in-node-js-16io</link>
      <guid>https://dev.to/kais_blog/how-to-generate-a-secure-random-number-in-node-js-16io</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/how-to-generate-a-secure-random-number-in-nodejs"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;




&lt;p&gt;While you are working on your JavaScript apps, the moment will come when you need a secure random number. Generating it has been quite tricky in the past. Some people use &lt;code&gt;Math.random&lt;/code&gt; whenever the need for a random number arises. Please don't do this if there is any chance for an attacker.&lt;/p&gt;

&lt;p&gt;If you are generating random numbers for security reasons (e.g. verification codes), you should use a cryptographically secure random number. Fortunately, the &lt;code&gt;crypto&lt;/code&gt; module has been extended in recent Node.js versions. So, now there's an easy way to do it in JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Node.js (v14.10.0+ / v12.19.0+)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Generate a Secure Random Number Between &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; in JavaScript
&lt;/h2&gt;

&lt;p&gt;Without further ado, let's generate our secure random number. First, import the &lt;code&gt;crypto&lt;/code&gt; module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;crypto&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;crypto&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you have access to the &lt;code&gt;randomInt&lt;/code&gt; function. &lt;code&gt;randomInt&lt;/code&gt; takes up to three arguments.&lt;/p&gt;

&lt;p&gt;Probably, you want to generate a random number in a given range. Therefore, you can specify the minimum (&lt;code&gt;min&lt;/code&gt;) and maximum (&lt;code&gt;max&lt;/code&gt;). Note that the minimum is &lt;em&gt;inclusive&lt;/em&gt; and the maximum is &lt;em&gt;exclusive&lt;/em&gt;. So, if you want to generate a number between 0 and 999,999 you'll have to pass &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;1000000&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Synchronous&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;randomInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The third argument is optional. You can provide a &lt;code&gt;callback&lt;/code&gt; function. Then, the random integer is generated asynchronously:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Asynchronous&lt;/span&gt;
&lt;span class="nx"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;randomInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Good! Now, &lt;code&gt;n&lt;/code&gt; is a secure random integer between &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;999999&lt;/code&gt;. For example, this could be used as a 6-digit verification code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;verificationCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;padStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The changes in recent Node.js versions made generating secure random numbers easy. So, if you are generating random numbers to use as verification codes or for a secure random shuffle, you now know how to do it.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/how-to-generate-a-secure-random-number-in-nodejs"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>tutorial</category>
      <category>security</category>
    </item>
    <item>
      <title>Did You Know These 14 Useful HTML Tags?</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Wed, 10 Feb 2021 15:58:29 +0000</pubDate>
      <link>https://dev.to/kais_blog/did-you-know-these-14-useful-html-tags-1j0j</link>
      <guid>https://dev.to/kais_blog/did-you-know-these-14-useful-html-tags-1j0j</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/did-you-know-these-14-useful-html-tags"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;




&lt;p&gt;HTML is a markup language. That means you are adding structure and semantics to your document by adding &lt;em&gt;tags&lt;/em&gt;. These tags help the browser rendering and also assists machines understanding your content.  Furthermore, they help in preventing accessibility issues. That's why you should take your time and add the right tags to your content.&lt;/p&gt;

&lt;p&gt;While HTML is widely known and used, there are still a lot of uncommon yet useful HTML tags. In this post I'd like to show you some awesome HTML tags you might not know.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&amp;lt;abbr&amp;gt;: Abbreviation&lt;/li&gt;
&lt;li&gt;&amp;lt;address&amp;gt;: Contact Address&lt;/li&gt;
&lt;li&gt;&amp;lt;blockquote&amp;gt;: Block Quotation&lt;/li&gt;
&lt;li&gt;&amp;lt;cite&amp;gt;: Citation&lt;/li&gt;
&lt;li&gt;&amp;lt;figure&amp;gt; &amp;amp; &amp;lt;figcaption&amp;gt;: Figure with Optional Caption&lt;/li&gt;
&lt;li&gt;&amp;lt;kbd&amp;gt;: Keyboard Input&lt;/li&gt;
&lt;li&gt;&amp;lt;map&amp;gt;: Image Map&lt;/li&gt;
&lt;li&gt;&amp;lt;noscript&amp;gt;: Visible If JavaScript Is Disabled&lt;/li&gt;
&lt;li&gt;&amp;lt;progress&amp;gt;: Progress Indicator&lt;/li&gt;
&lt;li&gt;&amp;lt;sub&amp;gt; &amp;amp; &amp;lt;sup&amp;gt;: Subscript &amp;amp; Superscript&lt;/li&gt;
&lt;li&gt;&amp;lt;var&amp;gt;: Variable&lt;/li&gt;
&lt;li&gt;&amp;lt;wbr&amp;gt;: Word Break Opportunity&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &amp;lt;abbr&amp;gt;: Abbreviation
&lt;/h2&gt;

&lt;p&gt;You can use the &lt;code&gt;&amp;lt;abbr&amp;gt;&lt;/code&gt; tag to define an abbreviation or an acronym. It helps a lot with web accessibility. In combination with the &lt;code&gt;title&lt;/code&gt; attribute you can add a little tooltip that is shown on hovering the element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;abbr&lt;/span&gt; &lt;span class="na"&gt;title=&lt;/span&gt;&lt;span class="s"&gt;"Hypertext Markup Language"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;HTML&lt;span class="nt"&gt;&amp;lt;/abbr&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/abbr"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/abbr&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &amp;lt;address&amp;gt;: Contact Address
&lt;/h2&gt;

&lt;p&gt;Use the &lt;code&gt;&amp;lt;address&amp;gt;&lt;/code&gt; tag to denote contact information for a person or an organization.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;address&amp;gt;&lt;/span&gt;
  John Doe&lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"mailto:john@example.com"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;john@example.com&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/address&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/address"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/address&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &amp;lt;blockquote&amp;gt;: Block Quotation
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;blockquote&amp;gt;&lt;/code&gt; tag indicates that the section is quoted from another source. You can also use the &lt;code&gt;cite&lt;/code&gt; attribute to add the URL for the source of the quotation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;blockquote&lt;/span&gt; &lt;span class="na"&gt;cite=&lt;/span&gt;&lt;span class="s"&gt;"https://alice.book"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    It's no use going back to yesterday, because I was a different person then.
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/blockquote&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &amp;lt;cite&amp;gt;: Citation
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;cite&amp;gt;&lt;/code&gt; tag is mostly used in conjunction with the &lt;code&gt;&amp;lt;blockquote&amp;gt;&lt;/code&gt; tag. It should be used to denote the title of the creative work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;blockquote&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
    It's no use going back to yesterday, because I was a different person then.
  &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;cite&amp;gt;&lt;/span&gt;Alice's Adventures in Wonderland&lt;span class="nt"&gt;&amp;lt;/cite&amp;gt;&lt;/span&gt; by Lewis Carroll
  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/blockquote&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/cite"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/cite&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &amp;lt;figure&amp;gt; &amp;amp; &amp;lt;figcaption&amp;gt;: Figure with Optional Caption
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;figure&amp;gt;&lt;/code&gt; tag lets you mark up self-contained content like a diagram or a photo. Use it in conjunction with the &lt;code&gt;&amp;lt;figcaption&amp;gt;&lt;/code&gt; tag to define a caption for the &lt;code&gt;&amp;lt;figure&amp;gt;&lt;/code&gt; element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;figure&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"diagram.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Net income of households by household type"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;figcaption&amp;gt;&lt;/span&gt;Fig.1 - Net income of households by household type&lt;span class="nt"&gt;&amp;lt;/figcaption&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/figure&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &amp;lt;kbd&amp;gt;: Keyboard Input
&lt;/h2&gt;

&lt;p&gt;With the &lt;code&gt;&amp;lt;kbd&amp;gt;&lt;/code&gt; tag you can define keyboard input. It's usually rendered in a monospace font.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  Open the task manager by pressing &lt;span class="nt"&gt;&amp;lt;kbd&amp;gt;&lt;/span&gt;Ctrl&lt;span class="nt"&gt;&amp;lt;/kbd&amp;gt;&lt;/span&gt; + &lt;span class="nt"&gt;&amp;lt;kbd&amp;gt;&lt;/span&gt;Alt&lt;span class="nt"&gt;&amp;lt;/kbd&amp;gt;&lt;/span&gt; + &lt;span class="nt"&gt;&amp;lt;kbd&amp;gt;&lt;/span&gt;Del&lt;span class="nt"&gt;&amp;lt;/kbd&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &amp;lt;map&amp;gt;: Image Map
&lt;/h2&gt;

&lt;p&gt;With the &lt;code&gt;&amp;lt;map&amp;gt;&lt;/code&gt; tag you can create an image with clickable areas. You can specify how different areas of the image should link to different URLs.&lt;/p&gt;

&lt;p&gt;For this, you'll have to add the &lt;code&gt;usemap&lt;/code&gt; attribute to your &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tag. Also, your map has to use multiple &lt;code&gt;&amp;lt;area&amp;gt;&lt;/code&gt; tags to denote the different areas.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"office.jpg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Floor plan"&lt;/span&gt; &lt;span class="na"&gt;usemap=&lt;/span&gt;&lt;span class="s"&gt;"#floorplan"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;map&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"floorplan"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;area&lt;/span&gt; &lt;span class="na"&gt;shape=&lt;/span&gt;&lt;span class="s"&gt;"rect"&lt;/span&gt; &lt;span class="na"&gt;coords=&lt;/span&gt;&lt;span class="s"&gt;"…"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Conference Room"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"conference-room.htm"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;area&lt;/span&gt; &lt;span class="na"&gt;shape=&lt;/span&gt;&lt;span class="s"&gt;"rect"&lt;/span&gt; &lt;span class="na"&gt;coords=&lt;/span&gt;&lt;span class="s"&gt;"…"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Kitchen"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"kitchen.htm"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  …
&lt;span class="nt"&gt;&amp;lt;/map&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unfortunately, explaining the usage of &lt;code&gt;&amp;lt;map&amp;gt;&lt;/code&gt; in detail is beyond the scope of this article.&lt;/p&gt;

&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/map"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/map&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &amp;lt;noscript&amp;gt;: Visible If JavaScript Is Disabled
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;noscript&amp;gt;&lt;/code&gt; tag only renders its contents if the user has JavaScript disabled. For example, you could add a small note they should enable JavaScript. If they have it enabled, this note is hidden.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;noscript&amp;gt;&lt;/span&gt;
  For full functionality of this site it is necessary to enable JavaScript. Please enable JavaScript in your browser.
&lt;span class="nt"&gt;&amp;lt;/noscript&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &amp;lt;progress&amp;gt;: Progress Indicator
&lt;/h2&gt;

&lt;p&gt;Use the &lt;code&gt;&amp;lt;progress&amp;gt;&lt;/code&gt; tag to show a progress bar for a task. Also, remember to add a &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt; tag for accessibility reasons.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"file"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Uploading progress&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;progress&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"file"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"28"&lt;/span&gt; &lt;span class="na"&gt;max=&lt;/span&gt;&lt;span class="s"&gt;"100"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;28%&lt;span class="nt"&gt;&amp;lt;/progress&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &amp;lt;sub&amp;gt; &amp;amp; &amp;lt;sup&amp;gt;: Subscript &amp;amp; Superscript
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;sub&amp;gt;&lt;/code&gt; tag defines subscript text. The contents are rendered with a lowered baseline using smaller text. This is useful e.g. for chemical formulas:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;Despite its dangers, Dihydrogen monoxide (H&lt;span class="nt"&gt;&amp;lt;sub&amp;gt;&lt;/span&gt;2&lt;span class="nt"&gt;&amp;lt;/sub&amp;gt;&lt;/span&gt;O) is often used.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Conveniently there is also a tag for superscript. The contents of the &lt;code&gt;&amp;lt;sup&amp;gt;&lt;/code&gt; tag are rendered with a raised baseline using smaller text. For example, you can use this for mathematical expressions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;a&lt;span class="nt"&gt;&amp;lt;sup&amp;gt;&lt;/span&gt;2&lt;span class="nt"&gt;&amp;lt;/sup&amp;gt;&lt;/span&gt; + b&lt;span class="nt"&gt;&amp;lt;sup&amp;gt;&lt;/span&gt;2&lt;span class="nt"&gt;&amp;lt;/sup&amp;gt;&lt;/span&gt; = c&lt;span class="nt"&gt;&amp;lt;sup&amp;gt;&lt;/span&gt;2&lt;span class="nt"&gt;&amp;lt;/sup&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &amp;lt;var&amp;gt;: Variable
&lt;/h2&gt;

&lt;p&gt;Use the &lt;code&gt;&amp;lt;var&amp;gt;&lt;/code&gt; tag to describe a variable in programming or in a mathematical expression.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;Given the width &lt;span class="nt"&gt;&amp;lt;var&amp;gt;&lt;/span&gt;w&lt;span class="nt"&gt;&amp;lt;/var&amp;gt;&lt;/span&gt; and the height &lt;span class="nt"&gt;&amp;lt;var&amp;gt;&lt;/span&gt;h&lt;span class="nt"&gt;&amp;lt;/var&amp;gt;&lt;/span&gt; you can calculate the area of the rectangle.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/var"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/var&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &amp;lt;wbr&amp;gt;: Word Break Opportunity
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;wbr&amp;gt;&lt;/code&gt; tag specifies a position within text where a line-break would be allowed. So, you can allow to break a (very) long word into multiple lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;Dampf&lt;span class="nt"&gt;&amp;lt;wbr&amp;gt;&lt;/span&gt;schiff&lt;span class="nt"&gt;&amp;lt;wbr&amp;gt;&lt;/span&gt;fahrt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example shows adding word break opportunities to a long german word.&lt;/p&gt;

&lt;p&gt;Further reading: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr"&gt;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;HTML has a lot of useful tags. Instead of using &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; for everything, try adding more semantics to your documents. Your site will become more friendly towards machines and humans.&lt;/p&gt;

&lt;p&gt;Did you know all of these tags? Please consider sharing this list with your friends and colleagues if it was interesting for you.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/did-you-know-these-14-useful-html-tags"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Install Node.js and npm on Windows or macOS</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Mon, 18 Jan 2021 10:48:53 +0000</pubDate>
      <link>https://dev.to/kais_blog/how-to-install-node-js-and-npm-on-windows-or-macos-4627</link>
      <guid>https://dev.to/kais_blog/how-to-install-node-js-and-npm-on-windows-or-macos-4627</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/how-to-install-nodejs-and-npm-on-windows-or-macos"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;




&lt;p&gt;Installing Node.js and npm on Windows or macOS is an easy task. Learn how to do it within a few minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Node.js and npm?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Node.js&lt;/strong&gt; is a JavaScript runtime that allows you to execute programs written in JavaScript. With Node.js JavaScript is not restricted to the browser anymore. In fact, by using Node.js you can &lt;a href="https://dev.to/kais_blog/javascript-is-everywhere-5fo0"&gt;create web, mobile and desktop apps&lt;/a&gt;. It's awesome! You should give it a try!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;npm&lt;/strong&gt; (originally short for &lt;em&gt;Node Package Manager&lt;/em&gt;) is a command-line-utility that's included with your Node.js installation. It acts as a package manager for JavaScript. With npm you can download so-called packages from a package registry (most of the time - the &lt;a href="https://www.npmjs.com/"&gt;&lt;em&gt;npm registry&lt;/em&gt;&lt;/a&gt;). These packages are provided by other developers and help you develop your applications. You can also publish your own packages and thus, share your code and take part in the community.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Install Node.js and npm
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Download and Run the Node.js Installer
&lt;/h3&gt;

&lt;p&gt;First, you have to download the installer. Navigate to:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nodejs.org/en/download/"&gt;https://nodejs.org/en/download/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Click&lt;/strong&gt; the &lt;strong&gt;Windows Installer&lt;/strong&gt; or &lt;strong&gt;macOS Installer&lt;/strong&gt; button. This starts downloading the latest, recommended Node.js version for Windows / macOS. Once the installer has finished downloading, you are ready to run it. So, browse to the location where you have saved the file and &lt;strong&gt;run the installer&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The installer will guide you through the steps. You can leave it with the defaults. When the installer has finished the installation, you are ready to use Node.js. Let's verify that everything works as intended in the next step.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Verify Your Node.js Installation
&lt;/h3&gt;

&lt;p&gt;After running the installer for Node.js, you should have access to the &lt;code&gt;node&lt;/code&gt; and the &lt;code&gt;npm&lt;/code&gt; command-line-utilities. Let's try it! Open the &lt;strong&gt;Windows Command Prompt&lt;/strong&gt; / &lt;strong&gt;Windows PowerShell&lt;/strong&gt; or &lt;strong&gt;Terminal&lt;/strong&gt; (macOS). Enter the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you should see the current Node.js version installed on your system. Let's try the same for npm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should show you the current npm version on your system. If everything works, you are ready to create your first simple Node.js program. If you see an error, try restarting your computer. Then, try again.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Create Your First Node.js Program
&lt;/h3&gt;

&lt;p&gt;Now that you have successfully installed Node.js and npm on your computer, you are ready to create your first Node.js program. Launch a text editor of your choice. Write the following line of &lt;strong&gt;JavaScript&lt;/strong&gt; into a new file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, world!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, save that file and name it &lt;code&gt;hello.js&lt;/code&gt;. Open your &lt;strong&gt;Windows Command Prompt / PowerShell&lt;/strong&gt; or &lt;strong&gt;Terminal&lt;/strong&gt; (macOS). Use it to navigate to the place where you've saved the file. Then, type in the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node hello.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see &lt;code&gt;Hello, world!&lt;/code&gt;. Nice! You've successfully created your first Node.js program. As you can see, you've executed JavaScript on your computer. Well, there's far too much to show you now. Just let me tell you something - learning Node.js is a valuable skill. You can create &lt;a href="https://dev.to/kais_blog/javascript-is-everywhere-5fo0"&gt;web, mobile and desktop apps with it. Even games!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have fun learning! See you around!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/how-to-install-nodejs-and-npm-on-windows-or-macos"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>JavaScript Is Everywhere</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Mon, 11 Jan 2021 14:16:01 +0000</pubDate>
      <link>https://dev.to/kais_blog/javascript-is-everywhere-5fo0</link>
      <guid>https://dev.to/kais_blog/javascript-is-everywhere-5fo0</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/javascript-is-everywhere"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;




&lt;p&gt;One of the major reasons &lt;a href="https://dev.to/kais_blog/7-reasons-why-you-should-learn-javascript-in-2021-7lg"&gt;why you should learn JavaScript in 2021&lt;/a&gt; is its omnipresence. You can find JavaScript everywhere. Conversly, this means that learning JavaScript is a valuable skill regardless of what you want to develop.&lt;/p&gt;

&lt;p&gt;With JavaScript, you can…&lt;/p&gt;

&lt;p&gt;🌐 …create websites / web apps and browser extensions. &lt;strong&gt;Check!&lt;/strong&gt;&lt;br&gt;
🖥️ …create desktop apps. &lt;strong&gt;Check!&lt;/strong&gt;&lt;br&gt;
📱 …create mobile apps. &lt;strong&gt;Check!&lt;/strong&gt;&lt;br&gt;
🎮 …create games. &lt;strong&gt;Check!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This leaves nothing to be desired. In this post I'll show you awesome JavaScript frameworks, libraries and tools for the different use-cases. The only limit is your imagination. Also, you'll find examples of possible applications. So, if you wonder whether JavaScript is &lt;em&gt;good enough&lt;/em&gt; - take a look at the examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌐 Frontend Development
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Frameworks / Libraries
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://angular.io/"&gt;Angular&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://aurelia.io/"&gt;Aurelia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://reactjs.org/"&gt;React&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.gatsbyjs.com/"&gt;Gatsby&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nextjs.org/"&gt;Next.js&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;a href="https://svelte.dev/"&gt;Svelte&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://vuejs.org/"&gt;Vue.js&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://gridsome.org/"&gt;Gridsome&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nuxtjs.org/"&gt;Nuxt.js&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;p&gt;Virtually every website uses JavaScript. I think that should give enough examples of the possible applications. Also, these frontend frameworks and libraries are used for the interfaces in desktop / mobile apps and games as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌐 Backend Development
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Runtimes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://nodejs.org/en/"&gt;Node.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://deno.land/"&gt;Deno&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Frameworks / Libraries
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://expressjs.com/"&gt;Express&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fastify.io/"&gt;Fastify&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hapi.dev/"&gt;hapi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://koajs.com/"&gt;Koa&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nestjs.com/"&gt;NestJS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.netflix.com/"&gt;Netflix&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.paypal.com/"&gt;PayPal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://trello.com/"&gt;Trello&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🖥️ Desktop Development
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Frameworks / Libraries
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://appjs.com/"&gt;AppJS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.electronjs.org/"&gt;Electron&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.nodegui.org/"&gt;NodeGui&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nwjs.io/"&gt;NW.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://proton-native.js.org/#/"&gt;Proton Native&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://discord.com/"&gt;Discord&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.postman.com/"&gt;Postman&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://slack.com/"&gt;Slack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📱 Mobile Development
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Frameworks / Libraries
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://cordova.apache.org/"&gt;Cordova&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ionicframework.com/"&gt;Ionic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.nativescript.org/"&gt;NativeScript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://facebook.github.io/react-native/"&gt;React Native&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://weex.apache.org/"&gt;Weex&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://play.google.com/store/apps/details?id=com.instagram.android"&gt;Instagram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://play.google.com/store/apps/details?id=com.pinterest"&gt;Pinterest&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://play.google.com/store/apps/details?id=com.wix.android"&gt;Wix&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🎮 Game Development
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Frameworks / Libraries
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.babylonjs.com/"&gt;Bablyon.js&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://colyseus.io/"&gt;Colyseus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gdevelop-app.com/"&gt;GDevelop&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://phaser.io/"&gt;Phaser&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.pixijs.com/"&gt;PixiJS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://store.steampowered.com/app/384630/Aviary_Attorney/"&gt;Aviary Attorney&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://store.steampowered.com/app/1040230/Curious_Expedition_2/"&gt;Curious Expedition 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://slither.io/"&gt;slither.io&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;There you have it. If anyone ever tells you again, that JavaScript can't be used here or there - think twice. They might be right, but that's almost never true. Some applications require something else than JavaScript. Though, for your typical use-case (like Netflix or PayPal, lol), JavaScript is &lt;em&gt;good enough&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;However, let me add that even these big companies probably have a more diverse tech stack. JavaScript is a puzzle piece that let's you move fast and focus on the bigger picture. If you need something else, you probably know it and choose accordingly.&lt;/p&gt;

&lt;p&gt;Have you tried creating something with JavaScript yet? Share your experience with us in the comments below.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/javascript-is-everywhere"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>7 Tips for Clean Code in JavaScript You Should Know</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Tue, 05 Jan 2021 22:00:51 +0000</pubDate>
      <link>https://dev.to/kais_blog/7-tips-for-clean-code-in-javascript-you-should-know-2533</link>
      <guid>https://dev.to/kais_blog/7-tips-for-clean-code-in-javascript-you-should-know-2533</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/7-tips-for-clean-code-in-javascript-you-should-know"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;




&lt;p&gt;As a developer, you'll spend much more time reading code than writing it. That's why it's important to write code that's quick to grasp and easy to maintain. In this post, I want to introduce you to 7 tips that will help you create a clean and robust codebase.&lt;/p&gt;

&lt;p&gt;Please note that these are opinionated guidelines. Some of you may not agree with me. In general, these tips will not be universal. Also, this list is not exhaustive at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Use meaningful names
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;There are only two hard things in Computer Science: cache invalidation and naming things.&lt;br&gt;
-- Phil Karlton&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yeah, naming things is hard. However, meaningless names will trigger chaos in the long run. Whenever you have to choose a name - be it for a variable, a class, a function or anything else - please use meaningful names. The name should tell you the purpose and context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;❌ Bad&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;su&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;U&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pw&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// What the §*{$ is this?&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;✔️ Good&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;signup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// Ah, now I understand!&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Replace magic numbers with constants
&lt;/h2&gt;

&lt;p&gt;What is a magic number? A magic number is a hard coded numeric value. It's an anti-pattern and obscures the developer's intent. Thus, it should be replaced with a constant that describes its purpose. See, you can instantly apply your knowledge from the first tip.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;❌ Bad&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;52&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...um, why again do we use `52` here?&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;✔️ Good&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;DECK_SIZE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;52&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;DECK_SIZE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// It's about a deck of playing cards.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you may ask why &lt;code&gt;i = 0&lt;/code&gt; is okay. Well, I'd count this as acceptable use. The intent here is clear - using &lt;code&gt;i&lt;/code&gt; and initializing it with &lt;code&gt;0&lt;/code&gt; is widely known among developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Do not use boolean flags to determine behavior
&lt;/h2&gt;

&lt;p&gt;Often, you encounter a function that has two very similar behaviors. To switch between those, you might be tempted to simply add a boolean flag. However, this makes your code less readable and harder to understand. Try to split the function into two functions without the flag instead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;❌ Bad&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;loadSchema&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;sync&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// One eternity later…&lt;/span&gt;

&lt;span class="nx"&gt;loadSchema&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;…&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Wait, what is `true` here? Sync? Async? &lt;/span&gt;
&lt;span class="c1"&gt;// Something else? I'm so forgetful.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;✔️ Good&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;loadSchema&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;loadSchemaSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// One eternity later…&lt;/span&gt;

&lt;span class="nx"&gt;loadSchemaSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;…&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Ah, it's the synchronous variant.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Reduce nesting in your code
&lt;/h2&gt;

&lt;p&gt;Nesting makes code harder to read and especially harder to understand. With some simple tricks you can reduce nesting to a minimum.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;❌ Bad&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;can&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CREATE_POST&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Wow, this is deep.&lt;/span&gt;
      &lt;span class="c1"&gt;// Handle request here.&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// User is not authorized.&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;403&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// User is not authenticated.&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;401&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;✔️ Good&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// User is not authenticated.&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;401&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;can&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CREATE_POST&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// User is not authorized.&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;403&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// We can safely assume the user&lt;/span&gt;
  &lt;span class="c1"&gt;// is authenticated and authorized.&lt;/span&gt;
  &lt;span class="c1"&gt;// Handle request here.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Make use of newer language features
&lt;/h2&gt;

&lt;p&gt;JavaScript is constantly changing. This brings you awesome new features that can improve your codebase. You can use destructuring, classes, the async-await syntax, the numeric separator and much more. My favorites are probably the spread-Operator (&lt;code&gt;...&lt;/code&gt;), the optional-chaining operator (&lt;code&gt;?.&lt;/code&gt;) and nullish-coalescing (&lt;code&gt;??&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;❌ Bad&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Assigning a default value should be easier...&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Did I mess up? It's nine zeros, right?&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;oneBillion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1000000000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Deep properties and nesting...urghs&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;team&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;team&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subscription&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;team&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;subscription&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;//&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;✔️ Good&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Let's use nullish-coalescing (`??`).&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// The numeric separator makes it easy to tell.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;oneBillion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;_000_000_000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Here, we can use optional-chaining.&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;team&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;subscription&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that you cannot use optional-chaining on a non-existent root object. So if &lt;code&gt;user&lt;/code&gt; could be &lt;code&gt;undefined&lt;/code&gt;, we'd have to check with something like &lt;code&gt;typeof user !== "undefined"&lt;/code&gt; first.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Make your code easy to refactor
&lt;/h2&gt;

&lt;p&gt;Refactoring is the restructuring of your code without changing the observable behavior. To make this easy, you should consider writing automated tests. Therefore, you can use testing frameworks like &lt;a href="https://jestjs.io/"&gt;Jest&lt;/a&gt;. If you are using automated tests you can verify that your code is behaving like you'd expect.&lt;/p&gt;

&lt;p&gt;Then, you are ready for refactoring. You can change your code however you want. As long as your tests are passing, everything is fine. This should enable you to be confident about your codebase. No more fear that you are accidentally breaking something.&lt;/p&gt;

&lt;p&gt;Unfortunately, setting up a testing framework like Jest is beyond the scope of this article. If you want, I can create a post about testing (and refactoring) your JavaScript code.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Use ESLint
&lt;/h2&gt;

&lt;p&gt;This is the final tip of this post. Use this awesome tool called &lt;a href="https://eslint.org/"&gt;ESLint&lt;/a&gt;. It's free and easy to use and surely will improve your codebase. It detects and fixes common problems. Also, you can install useful presets and plugins to detect even more and reformat your code according to a style guide.&lt;/p&gt;

&lt;p&gt;I use ESLint with plugins for &lt;a href="https://github.com/standard/eslint-config-standard"&gt;standard&lt;/a&gt; and &lt;a href="https://github.com/prettier/eslint-config-prettier"&gt;prettier&lt;/a&gt;. Besides, if I'm working with Vue, I'll add &lt;a href="https://github.com/vuejs/eslint-plugin-vue"&gt;eslint-plugin-vue&lt;/a&gt;. Unfortunately, explaining the installation and configuration of ESLint is also beyond the scope of this article. Tell me, if you'd like to hear more about this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Consider using TypeScript
&lt;/h2&gt;

&lt;p&gt;If you've read any of my posts in the past, you might know that I'm using TypeScript, a superset of JavaScript. It's basically JavaScript on steroids and helps you writing more robust and maintainable code. If you are still undecided, take a look at these &lt;a href="https://dev.to/kais_blog/6-reasons-why-you-should-learn-typescript-in-2021-31mi"&gt;6 Reasons Why You Should Learn TypeScript in 2021 &lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;There's so much more you can do to create a clean and maintainable codebase. With my post, you should have a overview about small things you can do to improve your code. In the future, I'll publish more content to make you a better programmer.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/7-tips-for-clean-code-in-javascript-you-should-know"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>6 Reasons Why You Should Learn TypeScript in 2021</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Sat, 02 Jan 2021 15:07:46 +0000</pubDate>
      <link>https://dev.to/kais_blog/6-reasons-why-you-should-learn-typescript-in-2021-31mi</link>
      <guid>https://dev.to/kais_blog/6-reasons-why-you-should-learn-typescript-in-2021-31mi</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/6-reasons-why-you-should-learn-typescript-in-2021"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;




&lt;p&gt;Woah, please wait a second. You are expecting 6 reasons why you should learn TypeScript in 2021. But, did I mention that TypeScript is basically just JavaScript on steroids? So, before reading this post, you should take a look at &lt;a href="https://dev.to/kais_blog/7-reasons-why-you-should-learn-javascript-in-2021-7lg"&gt;7 Reasons Why You Should Learn JavaScript in 2021&lt;/a&gt;. If you already know about JavaScript, just keep on reading.&lt;/p&gt;




&lt;h1&gt;
  
  
  TypeScript is JavaScript on steroids
&lt;/h1&gt;

&lt;p&gt;Yeah, I've said it again. But it's true. TypeScript is a superset of JavaScript. This basically means it's a layer on top of JavaScript that adds many awesome features. So, if you know JavaScript or you'd like to learn it - you can transfer this knowledge to TypeScript. And vice versa. More or less every reason about &lt;a href="https://dev.to/kais_blog/7-reasons-why-you-should-learn-javascript-in-2021-7lg"&gt;why you should learn JavaScript in 2021&lt;/a&gt;, applies to TypeScript as well.&lt;/p&gt;




&lt;h1&gt;
  
  
  TypeScript is loved by developers
&lt;/h1&gt;

&lt;p&gt;Looking at &lt;a href="https://insights.stackoverflow.com/survey/2020/#technology-most-loved-dreaded-and-wanted-languages-loved"&gt;StackOverflow's Developer Survey 2020&lt;/a&gt;, you'll find that TypeScript is #2 of the most loved programming languages. The awesome syntax combined with JavaScript's huge ecosystem contributes to this. But, many things people hate about JavaScript don't apply to TypeScript. That makes for a really enjoyable developer experience.&lt;/p&gt;




&lt;h1&gt;
  
  
  TypeScript helps avoid painful bugs
&lt;/h1&gt;

&lt;p&gt;JavaScript is sometimes quirky. With TypeScript's type checking system, many bugs (or features?!) are avoidable. Countless errors have occurred because you were expecting a number but a string was passed. If you are using TypeScript, this is a thing of the past. TypeScript's type system is one of the most advanced type systems you'll ever come across. And with the usage of &lt;a href="https://dev.to/kais_blog/11-awesome-typescript-utility-types-you-should-know-4a8j"&gt;utility types&lt;/a&gt; you can go even further.&lt;/p&gt;




&lt;h1&gt;
  
  
  TypeScript needs less code
&lt;/h1&gt;

&lt;p&gt;TypeScript's language features are awesome. You'll need less code to achieve the same or even better results. The type system lets you remove many type guard clauses in your code. Also, TypeScript adds many cool features such as optional chaining (&lt;code&gt;?.&lt;/code&gt;) and nullish coalescing (&lt;code&gt;??&lt;/code&gt;) before they are generally available. This means you can write the JavaScript of tomorrow today.&lt;/p&gt;




&lt;h1&gt;
  
  
  TypeScript makes the switch easier
&lt;/h1&gt;

&lt;p&gt;If you are coming from a traditional developer education, you probably have learned C# or Java. At least, those two are the dominating languages here in Germany's education system. Nevertheless, if your background involved more statically-typed languages, you'll feel much better using TypeScript instead of JavaScript. In my opinion, it felt even better than using C# and Java.&lt;/p&gt;




&lt;h1&gt;
  
  
  TypeScript is completely optional
&lt;/h1&gt;

&lt;p&gt;Everything in TypeScript is optional. You can still write dynamically-typed code if you want to. You don't have to use interfaces, the typing system or some other awesome new language feature. Yet, those features are always available at your fingertips. Maybe some part should be statically-typed, some other part should be dynamically-typed. With TypeScript, you can. Besides, the configuration file allows you to tell the compiler how it should behave. In the end, it's still JavaScript.&lt;/p&gt;




&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;TypeScript's popularity is on the rise. It takes the good parts of JavaScript and adds some awesome sprinkles on top. So, if you are learning a new programming language in 2021, why not try TypeScript? It might be overwhelming at first, but it's worth it in the long run. And remember, each reason &lt;a href="https://dev.to/kais_blog/7-reasons-why-you-should-learn-javascript-in-2021-7lg"&gt;why you should learn JavaScript in 2021&lt;/a&gt; also applies to TypeScript.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/6-reasons-why-you-should-learn-typescript-in-2021"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Cover Background Image by &lt;a href="https://unsplash.com/photos/C6duwascOEA"&gt;@joshuaearle (unsplash.com)&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>7 Reasons Why You Should Learn JavaScript in 2021</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Sat, 02 Jan 2021 15:07:19 +0000</pubDate>
      <link>https://dev.to/kais_blog/7-reasons-why-you-should-learn-javascript-in-2021-7lg</link>
      <guid>https://dev.to/kais_blog/7-reasons-why-you-should-learn-javascript-in-2021-7lg</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/7-reasons-why-you-should-learn-javascript-in-2021"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;




&lt;p&gt;It's the start of a new year. Many new year's resolutions are broken already. Nevertheless, have you ever thought about learning a new programming language in the new year? Why not start today? Here, I'll give you 7 reasons why you should start learning JavaScript in 2021!&lt;/p&gt;




&lt;h1&gt;
  
  
  JavaScript is the most popular language
&lt;/h1&gt;

&lt;p&gt;According to &lt;a href="https://insights.stackoverflow.com/survey/2020/#technology-programming-scripting-and-markup-languages-all-respondents"&gt;StackOverflow's Developer Survey 2020&lt;/a&gt;, JavaScript is the most commonly used programming language among developers. And that's for the eighth year in a row. Its popularity is even higher if you only look at professional developers.&lt;/p&gt;




&lt;h1&gt;
  
  
  JavaScript's ecosystem is huge
&lt;/h1&gt;

&lt;p&gt;The popularity results in tons of tutorials and libraries. I mean it. With &lt;a href="https://www.npmjs.com/"&gt;npm&lt;/a&gt; you have the largest package registry in the world - available at your fingertips. Also, millions of developers use JavaScript every day. And many of them aren't silent. You'll find a gigantic amount of tutorials in this mysterious thing called Internet.&lt;/p&gt;




&lt;h1&gt;
  
  
  JavaScript is omnipresent
&lt;/h1&gt;

&lt;p&gt;You are interested in backend, frontend or fullstack development? You want to create a web, desktop or mobile application? Or you dream of becoming a game developer? Everything is possible with JavaScript nowadays. Also, if you've ever heard of serverless functions - for those you can use JavaScript, too.&lt;/p&gt;




&lt;h1&gt;
  
  
  JavaScript is the language of browsers
&lt;/h1&gt;

&lt;p&gt;I hear you WebAssembly (WASM). JavaScript is not the only one. However, JavaScript is here to stay and WASM won't change this in the near future. If you are working on anything web-related there's (more or less) no way around JavaScript. You can create your backend in C# or Java, but if you are working in the frontend you'll probably have to face JavaScript.&lt;/p&gt;




&lt;h1&gt;
  
  
  JavaScript is fast and efficient
&lt;/h1&gt;

&lt;p&gt;Ever heard of Netflix or PayPal? Those two companies and a lot of other big and small names made the switch to JavaScript (Node.js). They found their web apps to be significantly faster and cheaper. Also, they took less time to develop and need less maintenance overall. A win-win situation.&lt;/p&gt;




&lt;h1&gt;
  
  
  JavaScript is easy and fun to learn
&lt;/h1&gt;

&lt;p&gt;Okay, that point is a bit more opinionated. However, with so many available tutorials, ebooks and interactive playgrounds, learning JavaScript is a fun endeavour. It's really easy to get started.&lt;/p&gt;




&lt;h1&gt;
  
  
  JavaScript is constantly evolving
&lt;/h1&gt;

&lt;p&gt;For some, this may be a negative. I find this very positive. JavaScript is constantly changing (for the better, in my opinion). New features and constructs are added regularly. With the rise of Babel and TypeScript you can use language features that aren't generally available yet. How cool is that!&lt;/p&gt;




&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Learning JavaScript in 2021 is a no-brainer. If you want to kickstart your developer career, JavaScript is worth a look. For some specific use-cases, other programming languages are ahead. However, you can always transfer your knowledge later to a certain extent. So, my recommendation for this year is: &lt;strong&gt;Learn JavaScript!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well, actually, my language of choice is TypeScript. It's a superset of JavaScript. Think of it as a layer on top of JavaScript adding many awesome features to the language. If I've sparked your interest, check out these &lt;a href="https://dev.to/kais_blog/6-reasons-why-you-should-learn-typescript-in-2021-31mi"&gt;6 Reasons Why You Should Learn TypeScript in 2021&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/7-reasons-why-you-should-learn-javascript-in-2021"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Cover Background Image by &lt;a href="https://unsplash.com/photos/oMpAz-DN-9I"&gt;@grakozy (unsplash.com)&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to Check For Undefined in JavaScript / TypeScript</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Fri, 01 Jan 2021 13:21:50 +0000</pubDate>
      <link>https://dev.to/kais_blog/how-to-check-for-undefined-in-javascript-typescript-3men</link>
      <guid>https://dev.to/kais_blog/how-to-check-for-undefined-in-javascript-typescript-3men</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/how-to-check-for-undefined-in-javascript-typescript"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;




&lt;p&gt;The correct way to check if something is undefined in JavaScript / TypeScript: Use the &lt;code&gt;typeof&lt;/code&gt; operator! It returns a string showing the type of the unevaluated operand.&lt;/p&gt;

&lt;p&gt;Let’s say you have an object &lt;code&gt;user&lt;/code&gt; that looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;kai@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you use the &lt;code&gt;typeof&lt;/code&gt; operator on the &lt;code&gt;email&lt;/code&gt; and &lt;code&gt;id&lt;/code&gt; property, you'll get this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "string"&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "undefined"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thus, to check for an undefined property you can combine an &lt;code&gt;if&lt;/code&gt;-statement and the &lt;code&gt;typeof&lt;/code&gt; operator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Easy! Yet, there are other ways to check for &lt;code&gt;undefined&lt;/code&gt;. However, those are sometimes quirky and will throw a &lt;code&gt;ReferenceError&lt;/code&gt;. So, I suggest that you always use the &lt;code&gt;typeof&lt;/code&gt; operator if you are checking for &lt;code&gt;undefined&lt;/code&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/how-to-check-for-undefined-in-javascript-typescript"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>npm displays badge for built-in TypeScript declarations</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Tue, 22 Dec 2020 11:12:18 +0000</pubDate>
      <link>https://dev.to/kais_blog/npm-displays-badge-for-built-in-typescript-declarations-217f</link>
      <guid>https://dev.to/kais_blog/npm-displays-badge-for-built-in-typescript-declarations-217f</guid>
      <description>&lt;p&gt;Good news for my fellow TypeScript developers!&lt;/p&gt;

&lt;p&gt;Since the 16th of December, npm displays a small TS badge for packages with bundled TypeScript declarations:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwz9ws4ilq3xijhlsq92m.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwz9ws4ilq3xijhlsq92m.jpg" alt="npm displays packages with bundled TypeScript declarations"&gt;&lt;/a&gt;&lt;br&gt;
(&lt;em&gt;example: &lt;a href="https://www.npmjs.com/package/vue" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/vue&lt;/a&gt;&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;This makes it easier to know, whether the maintainer supports TypeScript and if you have to use a package from the &lt;code&gt;@types&lt;/code&gt; repository.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Find GitHub's original announcement here: &lt;a href="https://github.blog/changelog/2020-12-16-npm-displays-packages-with-bundled-typescript-declarations/" rel="noopener noreferrer"&gt;npm displays packages with bundled TypeScript declarations&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>news</category>
      <category>npm</category>
      <category>webdev</category>
    </item>
    <item>
      <title>11 Awesome TypeScript Utility Types You Should Know</title>
      <dc:creator>Kai</dc:creator>
      <pubDate>Mon, 21 Dec 2020 13:17:35 +0000</pubDate>
      <link>https://dev.to/kais_blog/11-awesome-typescript-utility-types-you-should-know-4a8j</link>
      <guid>https://dev.to/kais_blog/11-awesome-typescript-utility-types-you-should-know-4a8j</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/11-awesome-typescript-utility-types-you-should-know"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;




&lt;p&gt;My last two posts have already shown you &lt;a href="https://dev.to/kais_blog/14-awesome-javascript-array-tips-you-should-know-about-1d0m"&gt;14 Awesome JavaScript Array Tips You Should Know About&lt;/a&gt; and &lt;a href="https://dev.to/kais_blog/10-awesome-javascript-string-tips-you-might-not-know-about-4ep2"&gt;10 Awesome JavaScript String Tips You Might Not Know About&lt;/a&gt;. However, I usually write code in TypeScript. There's also much to learn. So today, I'd like to show you 11 awesome TypeScript utility types. With these, constructing new types becomes a breeze.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pick&amp;lt;Type, Keys&amp;gt;&lt;/li&gt;
&lt;li&gt;Omit&amp;lt;Type, Keys&amp;gt;&lt;/li&gt;
&lt;li&gt;Readonly&amp;lt;Type&amp;gt;&lt;/li&gt;
&lt;li&gt;Partial&amp;lt;Type&amp;gt;&lt;/li&gt;
&lt;li&gt;Required&amp;lt;Type&amp;gt;&lt;/li&gt;
&lt;li&gt;Record&amp;lt;Keys, Type&amp;gt;&lt;/li&gt;
&lt;li&gt;Parameters&amp;lt;Type&amp;gt;&lt;/li&gt;
&lt;li&gt;ReturnType&amp;lt;Type&amp;gt;&lt;/li&gt;
&lt;li&gt;Extract&amp;lt;Type, Union&amp;gt;&lt;/li&gt;
&lt;li&gt;Exclude&amp;lt;Type, ExcludedUnion&amp;gt;&lt;/li&gt;
&lt;li&gt;NonNullable&amp;lt;Type&amp;gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don't have to do anything special. All utility types are globally available by default.&lt;/p&gt;

&lt;h1&gt;
  
  
  Pick&amp;lt;Type, Keys&amp;gt;
&lt;/h1&gt;

&lt;p&gt;With &lt;code&gt;Pick&lt;/code&gt; you can pick a set of &lt;code&gt;Keys&lt;/code&gt; from the given &lt;code&gt;Type&lt;/code&gt;. The example shows a &lt;code&gt;signup&lt;/code&gt; function taking a &lt;code&gt;user&lt;/code&gt; as first parameter. The parameter type is constructed by picking the &lt;code&gt;email&lt;/code&gt; and &lt;code&gt;password&lt;/code&gt; property from the &lt;code&gt;User&lt;/code&gt; type. This way, you won't need to pass an &lt;code&gt;id&lt;/code&gt; for signing up a new user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;signup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Pick&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;signup&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;kai@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;secret&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Omit&amp;lt;Type, Keys&amp;gt;
&lt;/h1&gt;

&lt;p&gt;In contrast to &lt;code&gt;Pick&lt;/code&gt;, you can use &lt;code&gt;Omit&lt;/code&gt; to remove a set of &lt;code&gt;Keys&lt;/code&gt; from your &lt;code&gt;Type&lt;/code&gt;. The example is similar to the previous. In this case, the &lt;code&gt;signup&lt;/code&gt; function's parameter &lt;code&gt;user&lt;/code&gt; has all properties from the &lt;code&gt;User&lt;/code&gt; type minus the &lt;code&gt;id&lt;/code&gt; property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;signup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Omit&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;signup&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;kai@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;secret&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Readonly&amp;lt;Type&amp;gt;
&lt;/h1&gt;

&lt;p&gt;Sometimes you want to prevent that an object's properties are reassigned. This is doable with the &lt;code&gt;Readonly&lt;/code&gt; utility type. The constructed type will have all properties set to read-only. Thus, you can't reassign any property of that type. In the following example, we'll create a new type by using &lt;code&gt;Readonly&lt;/code&gt; and the &lt;code&gt;User&lt;/code&gt; type. We can't reassign the &lt;code&gt;password&lt;/code&gt; property here, because it's read-only now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Readonly&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;d70989c8-c135-4825-a18c-a62ddf9ae1d5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;kai@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;secret&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;correcthorsebatterystaple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ERROR: Cannot assign to 'password' because it is a read-only property.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Partial&amp;lt;Type&amp;gt;
&lt;/h1&gt;

&lt;p&gt;Using &lt;code&gt;Partial&lt;/code&gt; you can construct a type with all properties from &lt;code&gt;Type&lt;/code&gt; set to optional. For example, the &lt;code&gt;updateUser&lt;/code&gt; function allows you to update a &lt;code&gt;User&lt;/code&gt;. The second parameter expects the fields to update. You can use &lt;code&gt;Partial&lt;/code&gt; with the &lt;code&gt;User&lt;/code&gt; type here, so that &lt;code&gt;fields&lt;/code&gt; is any combination of fields from the &lt;code&gt;User&lt;/code&gt; type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;updateUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Partial&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;d70989c8-c135-4825-a18c-a62ddf9ae1d5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;kai@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;secret&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;updateUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;correcthorsebatterystaple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Required&amp;lt;Type&amp;gt;
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;Required&lt;/code&gt; is the opposite of &lt;code&gt;Partial&lt;/code&gt;. You can use it to construct a type with all properties from &lt;code&gt;Type&lt;/code&gt; set to required. The following example has a &lt;code&gt;User&lt;/code&gt; type with an optional &lt;code&gt;avatar&lt;/code&gt; property. However, our variable &lt;code&gt;userWithAvatar&lt;/code&gt; requires all properties to be present. Thus, an error occurs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;avatar&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userWithAvatar&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Required&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;d70989c8-c135-4825-a18c-a62ddf9ae1d5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;kai@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;secret&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// ERROR: Property 'avatar' is missing in type '{ id: string; email: string; password: string; }' but required in type 'Required&amp;lt;User&amp;gt;'.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Record&amp;lt;Keys, Type&amp;gt;
&lt;/h1&gt;

&lt;p&gt;With the &lt;code&gt;Record&lt;/code&gt; utility type, you can easily construct a new type with &lt;code&gt;Keys&lt;/code&gt; as keys and &lt;code&gt;Type&lt;/code&gt; as values. In this example, each &lt;code&gt;User&lt;/code&gt; has a role. We want to describe an object that groups &lt;code&gt;userA&lt;/code&gt; and &lt;code&gt;userB&lt;/code&gt; by their respective role. Using &lt;code&gt;Record&lt;/code&gt;, we can tell the TypeScript compiler that the object has a &lt;code&gt;string&lt;/code&gt;s as keys and an array of &lt;code&gt;User&lt;/code&gt;s as values. Besides, to be more explicit, we could have used &lt;code&gt;User["role"]&lt;/code&gt; instead of &lt;code&gt;string&lt;/code&gt; for the keys.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userA&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;d70989c8-c135-4825-a18c-a62ddf9ae1d5&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;kai@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;secret&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;administrator&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userB&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;c0e26c7e-9787-4d56-81b4-4440759e251c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;katharina@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;correcthorsebatterystaple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;moderator&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;usersGroupedByRole&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;administrator&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;userA&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;moderator&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;userB&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Parameters&amp;lt;Type&amp;gt;
&lt;/h1&gt;

&lt;p&gt;Use &lt;code&gt;Parameters&lt;/code&gt; to extract a function's parameters. This will construct a tuple type with the parameters. Let's say you'd like to initialize a variable that holds parameters for a &lt;code&gt;signup&lt;/code&gt; function. With the help of &lt;code&gt;Parameters&lt;/code&gt; you can extract the &lt;code&gt;signup&lt;/code&gt; function's parameters and create a tuple type. Then, you can use the &lt;code&gt;parameters&lt;/code&gt; whenever you want.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;signup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;SignupParameters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Parameters&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;signup&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//                    = [email: string, password: string]&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SignupParameters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;kai@example.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;secret&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;signup&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  ReturnType&amp;lt;Type&amp;gt;
&lt;/h1&gt;

&lt;p&gt;The utility type &lt;code&gt;ReturnType&lt;/code&gt; helps by extracting the return type of a function. Look at the following example. We want our &lt;code&gt;ValidationResult&lt;/code&gt; type to be constructed by looking at the return type of the &lt;code&gt;validate&lt;/code&gt; function. Here, it's pretty simple. You could have used &lt;code&gt;boolean&lt;/code&gt; directly instead. However, sometimes it's nice to be able to extract a function's return type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;//&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;ValidationResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ReturnType&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;validate&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//                    = boolean&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Extract&amp;lt;Type, Union&amp;gt;
&lt;/h1&gt;

&lt;p&gt;Sometimes, you'd like to extract types from an union of types. For that, you can use the &lt;code&gt;Extract&lt;/code&gt; utility type. Every union member from &lt;code&gt;Type&lt;/code&gt; that is assignable to the &lt;code&gt;Union&lt;/code&gt; is kept.  In the following examples, we'll have unions of strings. There, we extract a part of it for our types &lt;code&gt;TypeA&lt;/code&gt; and &lt;code&gt;TypeB&lt;/code&gt;. For &lt;code&gt;TypeC&lt;/code&gt; we extract each union member that is assignable to &lt;code&gt;Function&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;TypeA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Extract&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banana&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cherry&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//         = "apple"&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;TypeB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Extract&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banana&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cherry&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banana&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//         = "apple" | "banana"&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;TypeC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Extract&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nb"&gt;Function&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//         = () =&amp;gt; string&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Exclude&amp;lt;Type, ExcludedUnion&amp;gt;
&lt;/h1&gt;

&lt;p&gt;The &lt;code&gt;Exclude&lt;/code&gt; utility type is the opposite of the &lt;code&gt;Extract&lt;/code&gt; utility type. This time, it removes all union members from &lt;code&gt;Type&lt;/code&gt; that are assignable to the &lt;code&gt;ExcludedUnion&lt;/code&gt;. Similar to the previous examples, we have unions of strings here. In contrast to last time, we are removing union members instead of keeping them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;TypeA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Exclude&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banana&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cherry&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//         = "banana" | "cherry"&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;TypeB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Exclude&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banana&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cherry&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;banana&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//         = "cherry"&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;TypeC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Exclude&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nb"&gt;Function&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//         = string&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  NonNullable&amp;lt;Type&amp;gt;
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;NonNullable&lt;/code&gt; works similar to the &lt;code&gt;Exclude&lt;/code&gt; utility type. It excludes &lt;code&gt;null&lt;/code&gt; and &lt;code&gt;undefined&lt;/code&gt; from the given &lt;code&gt;Type&lt;/code&gt;. Similar to the previous two examples, we construct the new types &lt;code&gt;TypeA&lt;/code&gt; and &lt;code&gt;TypeB&lt;/code&gt; by removing union members from a given &lt;code&gt;Type&lt;/code&gt;. Here, &lt;code&gt;null&lt;/code&gt; and/or &lt;code&gt;undefined&lt;/code&gt; are removed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;TypeA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;NonNullable&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//         = "apple"&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;TypeB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;NonNullable&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;apple&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;//         = "apple"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;This was a quick overview of some of the most useful utility types. They can be used for a wide range of things. I use them in almost every project. However, there are more utility types. Check out the &lt;a href="https://www.typescriptlang.org/docs/handbook/utility-types.html"&gt;official documentation&lt;/a&gt; to learn more! Besides, you can find even more such types. For example, the &lt;a href="https://github.com/sindresorhus/type-fest"&gt;&lt;code&gt;type-fest&lt;/code&gt;&lt;/a&gt; package adds many essential types to your project.&lt;/p&gt;

&lt;p&gt;Thanks a lot for reading this post. Please consider sharing it with your friends and colleagues. See you soon!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Let's move your learning forward together!&lt;/strong&gt; &lt;a href="https://twitter.com/intent/follow?screen_name=kais_blog"&gt;Follow me on Twitter&lt;/a&gt; for your daily dose of developer tips. Thanks for reading my content!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was originally published at &lt;a href="https://kais.blog/p/11-awesome-typescript-utility-types-you-should-know"&gt;kais.blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
