{"componentChunkName":"component---src-templates-blog-list-js","path":"/blog/7/","result":{"data":{"allMarkdownRemark":{"edges":[{"node":{"id":"39d14a3b-556c-523f-9ba4-5fb9f9d3d866","html":"<p>Lazy loading resources is one of the important parts of web performance tuning, simply because offscreen resources can add a lot of weight to your page if loaded eagerly.</p>\n<!--more-->\n<h2 id=\"intro\" style=\"position:relative;\"><a href=\"#intro\" aria-label=\"intro permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Intro</h2>\n<p>I’ve gone through many tips and tricks in my <a href=\"https://yashints.dev/blog/2018/11/12/web-perf-4\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">image optimisation article</a> which is <a href=\"https://dev.to/yashints/improve-html-and-css-performance-4o08\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">one of the series I’ve done on web performance</a>. However, when it comes to lazy loading, I mentioned that you have two options:</p>\n<ul>\n<li>Use <code class=\"language-text\">data-src</code> attribute on <code class=\"language-text\">&lt;img></code> tag and hook into either of <code class=\"language-text\">scroll</code>, <code class=\"language-text\">resize</code>, or <code class=\"language-text\">orientationChange</code> to figure out when to replace the <code class=\"language-text\">data-src</code> with <code class=\"language-text\">src</code> to make the call.</li>\n<li>Use <code class=\"language-text\">IntersectionObserver</code> API to asynchronously observe the changes and make the call when the item in is the viewport.</li>\n</ul>\n<p>The good news is, from <a href=\"https://www.google.com.au/chrome/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Chrome</a> 76, you can use the <code class=\"language-text\">loading</code> attribute of an image tag to tell the browser how to load the image.</p>\n<p>In fact it’s so simple that you won’t believe it 🤯:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"67549494693796120000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<img src=&quot;../path/to/image.jpg&quot; loading=&quot;lazy&quot;>`, `67549494693796120000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>../path/to/image.jpg<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">loading</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>lazy<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>I’ve created a demo to show you how it works, look closely on the network tab.</p>\n<p><img src=\"/1827f7c8b9ed52279a64a0fab330f8d9/loading.gif\" alt=\"Lazy loading images natively in Chorme\"></p>\n<p><a href=\"https://codepen.io/yashints/pen/VwZpKYY/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Here is a CodePen which contains the code</a>.</p>\n<p>I’ve just used below bash script to hack together the HTML 🤷🏽‍♂️.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"73107636201159980000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`for i in {400..499}; \r\n> do echo &quot;<img loading='lazy' \r\nsrc='https://placedog.net/\\${i}/\\${i}' height='\\${i}' width='\\${i}' />&quot;; \r\n> done`, `73107636201159980000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token keyword\">for</span> <span class=\"token for-or-select variable\">i</span> <span class=\"token keyword\">in</span> <span class=\"token punctuation\">{</span><span class=\"token number\">400</span><span class=\"token punctuation\">..</span><span class=\"token number\">499</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span> \r\n<span class=\"token operator\">></span> <span class=\"token keyword\">do</span> <span class=\"token builtin class-name\">echo</span> <span class=\"token string\">\"&lt;img loading='lazy' \r\nsrc='https://placedog.net/<span class=\"token variable\">${i}</span>/<span class=\"token variable\">${i}</span>' height='<span class=\"token variable\">${i}</span>' width='<span class=\"token variable\">${i}</span>' />\"</span><span class=\"token punctuation\">;</span> \r\n<span class=\"token operator\">></span> <span class=\"token keyword\">done</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"about-the-attribute\" style=\"position:relative;\"><a href=\"#about-the-attribute\" aria-label=\"about the attribute permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>About the attribute</h2>\n<p>Currently the images are fetched with different priority in <a href=\"https://www.google.com.au/chrome/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Chrome</a>, the ones which are not in the viewport have less priority. But they’re fetched as soon as possible regardless.</p>\n<p>With this new <code class=\"language-text\">loading</code> attribute, you can completely defer the loading of offscreen images (and <strong>iframes</strong>) to when they’re reached by scrolling:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"37514763686938250000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<img src=&quot;../path/to/image.jpg&quot; loading=&quot;lazy&quot;>\r\n<iframe src=&quot;https://placedog.net&quot; loading=&quot;lazy&quot;></iframe>`, `37514763686938250000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>../path/to/image.jpg<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">loading</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>lazy<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>iframe</span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://placedog.net<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">loading</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>lazy<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>iframe</span><span class=\"token punctuation\">></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>You can use three values with this attribute:</p>\n<ul>\n<li><code class=\"language-text\">auto</code>: Default behaviour of the browser, equal to not including the attribute.</li>\n<li><code class=\"language-text\">lazy</code>: Defer loading of resources until it reaches a <a href=\"https://web.dev/native-lazy-loading#load-in-distance-threshold\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">calculated distance</a> from viewport.</li>\n<li><code class=\"language-text\">eager</code>: Load the resource immediately</li>\n</ul>\n<p>My <a href=\"https://www.google.com.au/chrome/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Chrome</a> version is <code class=\"language-text\">76.0.3809.100</code> as of writing this post, but if you have any of the previous version below 76, you can activate this using flags:</p>\n<ul>\n<li>For images 👉🏽 <code class=\"language-text\">chrome://flags/#enable-lazy-image-loading</code></li>\n<li>For iframes 👉🏽 <code class=\"language-text\">chrome://flags/#enable-lazy-frame-loading</code></li>\n</ul>\n<h2 id=\"feature-detection\" style=\"position:relative;\"><a href=\"#feature-detection\" aria-label=\"feature detection permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Feature detection</h2>\n<p>If you want to use this attribute today, you can use below code to feature detect it and have a polyfill in place such as <a href=\"https://github.com/mfranzke/loading-attribute-polyfill\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">loading-attribute-polyfill</a>.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"81036389821759680000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`if ('loading' in HTMLImageElement.prototype === true) {\r\n  // use the attribute\r\n} else {\r\n  // use polyfill\r\n}`, `81036389821759680000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"typescript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-typescript line-numbers\"><code class=\"language-typescript\"><span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span><span class=\"token string\">'loading'</span> <span class=\"token keyword\">in</span> HTMLImageElement<span class=\"token punctuation\">.</span>prototype <span class=\"token operator\">===</span> <span class=\"token boolean\">true</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token comment\">// use the attribute</span>\r\n<span class=\"token punctuation\">}</span> <span class=\"token keyword\">else</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token comment\">// use polyfill</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"prevent-content-reflow\" style=\"position:relative;\"><a href=\"#prevent-content-reflow\" aria-label=\"prevent content reflow permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Prevent content reflow</h2>\n<p>Since the images are lazy loaded, if you haven’t set <code class=\"language-text\">width</code> and <code class=\"language-text\">height</code> for your image, the content might reflow when the image is loaded and fill its place. To prevent that to happen, simply set the required values on the image tag by either <code class=\"language-text\">style</code> or directly using <code class=\"language-text\">width</code> and <code class=\"language-text\">height</code> attributes:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"4792709798682915000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<img src=&quot;../path/to/image.jpg&quot; \r\nloading=&quot;lazy&quot; width=&quot;200&quot; height=&quot;200&quot;>\r\n\r\n<img src=&quot;../path/to/image.jpg&quot; \r\nloading=&quot;lazy&quot; style=&quot;height:200px; width:200px;&quot;>`, `4792709798682915000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>../path/to/image.jpg<span class=\"token punctuation\">\"</span></span> \r\n<span class=\"token attr-name\">loading</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>lazy<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">width</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>200<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">height</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>200<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>../path/to/image.jpg<span class=\"token punctuation\">\"</span></span> \r\n<span class=\"token attr-name\">loading</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>lazy<span class=\"token punctuation\">\"</span></span> <span class=\"token special-attr\"><span class=\"token attr-name\">style</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span><span class=\"token value css language-css\"><span class=\"token property\">height</span><span class=\"token punctuation\">:</span>200px<span class=\"token punctuation\">;</span> <span class=\"token property\">width</span><span class=\"token punctuation\">:</span>200px<span class=\"token punctuation\">;</span></span><span class=\"token punctuation\">\"</span></span></span><span class=\"token punctuation\">></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"iframe-loading\" style=\"position:relative;\"><a href=\"#iframe-loading\" aria-label=\"iframe loading permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>iframe loading</h2>\n<p>The same behaviour is applied to <code class=\"language-text\">iframe</code> when it’s used with <code class=\"language-text\">loading</code> attribute. However, there are times when an iframe is hidden for analytics purposes. Examples are they are very small (less than <code class=\"language-text\">4px</code> in width and height), or they have <code class=\"language-text\">display:none</code> or <code class=\"language-text\">visibility: hidden</code> applied to them, or simply is offscreen using negative margin.</p>\n<p>In these cases it won’t get lazy loaded even if you have used the attribute.</p>\n<h2 id=\"whats-the-catch\" style=\"position:relative;\"><a href=\"#whats-the-catch\" aria-label=\"whats the catch permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What’s the catch</h2>\n<p>There are few points you have to consider when using lazy loading in general. Plus there are a few things you can’t do with the <code class=\"language-text\">loading</code> attribute as of now.</p>\n<p><strong>Can’t do</strong></p>\n<ul>\n<li>You can’t change the threshold to load the resource for now since it’s been hard coded in the source.</li>\n<li>This can’t be used with CSS’ background image for now</li>\n</ul>\n<p><strong>Catches</strong></p>\n<ul>\n<li>This might affect the third party ads since they will be lazy loaded too</li>\n<li>There will be side effect when printing 😉, as in the lazy loaded resources won’t be printed. However, there is an <a href=\"https://bugs.chromium.org/p/chromium/issues/detail?id=875403\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">open issue</a> you can follow.</li>\n</ul>\n<h2 id=\"what-about-other-browsers\" style=\"position:relative;\"><a href=\"#what-about-other-browsers\" aria-label=\"what about other browsers permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What about other browsers?</h2>\n<p>For now, <a href=\"https://www.google.com.au/chrome/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Chrome</a> is the only browser supporting this feature. Although there is an <a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=1542784\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">open bug for Firefox</a> and nothing for Edge and IE.</p>\n<p>Happy lazy loading everybody and make sure not to miss the catches 👋🏽.</p>","timeToRead":3,"frontmatter":{"title":"Native lazy loading is landed in Chrome","unformattedDate":"2019-08-25T00:00:00.000Z","date":"Aug 25, 2019","path":"/native-lazyloading/","author":"Yaser Adel Mehraban","tags":["showdev","webdev","chrome","lazyloading"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAAsTAAALEwEAmpwYAAACRElEQVR42oWS30tTYRjH9090ZUQQQdKVEBL9C9FF0SSoM47nvO9wDdFyuh/mOKWFNStpboIu2o/cxubOds7Z2VZujqW5RjdeFEjNIlBjy6XbOds0y/XupCQpBg/vzcvn+32e5/vIAFs6vCCzDpk1yK7v/5IdBAiAK4OwiDCCqygi21ikhvNb/4chJxBcFffncV9OwW+3Bz6ZbGPjZh3lCiMhwBYPgwmm1OlKdzlmNK5Z8+j92O0zrw0Nmd4jqb4TGncGZzf29v8XhmxRwVYH6bls0vImNBSnmjLGo+mBxtn+0ymqMTXQpA0u4NEamuUgGE0Y2bTax2doK++xvLrbHOk65gQNT5Un54zHLeqzVykn6XhfXwdT/AcuAq7S5kp39N2yPtBadZciulOUFsq7R+7BZv7OuY7+4RasDVPrYPQH2DWXIUOlVCQrQM+Hm5PT0J99Mnh9woQZ/G+JeG10RD/xkOjklsipGkRB7NmZDOcrWPQnHtsEXAmEyzAsKjlx2G5/ZtbAUIFkiir669DzSRW9QjL7orrh/my0ZXps7wC9I0mwZTW31hP62MpV68mFN0geSQvSUlGWUv2B5+UX5tXdi9qLJucLjP8F6RwaiQx8w73LwPuF9C2T7kX0glAB0PlWpoSHdgqFKnvklV+21hKpMc+040qopmRW6/70KvAtkYEcCORJ3woIFpAiEfyuj4uGhKCPC7q42B4RZPKX5zt4VTbV8jiWvMZsKbni7oWK9VY56VSlnpFVb0KkkqJ2StRL8G/iwPSSNvtkYwAAAABJRU5ErkJggg=="},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/78f70ef2f2bafa692761cf7602393772/e0c1a/lazy-load.png","srcSet":"/static/78f70ef2f2bafa692761cf7602393772/e0c1a/lazy-load.png 730w","sizes":"(min-width: 730px) 730px, 100vw"},"sources":[{"srcSet":"/static/78f70ef2f2bafa692761cf7602393772/9fb36/lazy-load.webp 730w","type":"image/webp","sizes":"(min-width: 730px) 730px, 100vw"}]},"width":730,"height":478}}}}}},{"node":{"id":"a5f65ad5-7230-5b8d-8e21-01f67d24897a","html":"<p>Sometimes you want to connect to internet without someone watching you. This can be due to restrictions applied by governments, ISPs, etc. Maintaining privacy while using internet is very important to some people, and for me personally, the experience was to bypass a ridiculous censor on sites like Twitter and software like Telegram.</p>\n<!--more-->\n<p>So I thought how hard can it be to setup a VPN server (because I didn’t want to pay $5 per month) for a web developer. After Googling a bit, I found out you could easily do this on AWS for free using <a href=\"https://openvpn.net/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">OpenVPN</a>. I started setting it up and a couple of mins later I had it up and running.</p>\n<blockquote>\n<p><a href=\"https://openvpn.net/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">OpenVPN</a> is a popular open-source tool that is well tested and give you a production ready VPN solution.</p>\n</blockquote>\n<p>So just to not forget how I did it, as usual I thought let’s write up something, and who knows, maybe it was useful to you too 😉.</p>\n<p>So are you ready?</p>\n<h2 id=\"aws-console\" style=\"position:relative;\"><a href=\"#aws-console\" aria-label=\"aws console permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>AWS console</h2>\n<p>If you don’t have an account on <a href=\"https://aws.amazon.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">AWS (Amazon Web Services)</a>, go ahead and create one. It’s free, but you will need to have your credit card info handy.</p>\n<p>Once signed up, login and under the services menu look for EC2 (you can type and it will filter the services as you type).</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/db3d399d267774478d124f4853a0fa21/f43b1/awsservices.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 40%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAIABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB2wQH/8QAFhAAAwAAAAAAAAAAAAAAAAAAAAIS/9oACAEBAAEFAoUhSFP/xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAXEAADAQAAAAAAAAAAAAAAAAAAATKR/9oACAEBAAY/ApWErCVh/8QAFBABAAAAAAAAAAAAAAAAAAAAEP/aAAgBAQABPyFUpX//2gAMAwEAAgADAAAAEIPP/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPxA//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPxA//8QAGxAAAQUBAQAAAAAAAAAAAAAAAQARIUFR0TH/2gAIAQEAAT8QLzVYQhvGOKIN5Y4v/9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Selecting EC2 services from AWS console\"\n        title=\"\"\n        src=\"/static/db3d399d267774478d124f4853a0fa21/47311/awsservices.jpg\"\n        srcset=\"/static/db3d399d267774478d124f4853a0fa21/6f81f/awsservices.jpg 270w,\n/static/db3d399d267774478d124f4853a0fa21/09d21/awsservices.jpg 540w,\n/static/db3d399d267774478d124f4853a0fa21/47311/awsservices.jpg 1080w,\n/static/db3d399d267774478d124f4853a0fa21/f43b1/awsservices.jpg 1426w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>Click on EC2 and you will be redirected to its dashboard. Click launch instance button under create instance section.</p>\n<h2 id=\"select-the-openvpn\" style=\"position:relative;\"><a href=\"#select-the-openvpn\" aria-label=\"select the openvpn permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Select the OpenVPN</h2>\n<p>Many articles will walk you through setting up an new Linux VM and installing the <strong>OpenVPN</strong> manually. However, things have changed and some lovely people have put a ready to use service in the AWS marketplace, so we will choose that.</p>\n<p>Once in the dashboard, click <code class=\"language-text\">AWS Marketplace</code> menu from left and type OpenVPN, then press enter.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1013px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/dc6ac5c27b83c8abb490e0a59df408d9/326df/awsmarket.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 39.62962962962963%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAIABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB2KFB/8QAFxAAAwEAAAAAAAAAAAAAAAAAAAITEv/aAAgBAQABBQLCE0Jof//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABgQAAMBAQAAAAAAAAAAAAAAAAAykQIB/9oACAEBAAY/Al5BcwXMP//EABcQAQEBAQAAAAAAAAAAAAAAAADxAeH/2gAIAQEAAT8hnmcYnH//2gAMAwEAAgADAAAAEAAP/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPxA//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPxA//8QAHBAAAQMFAAAAAAAAAAAAAAAAAQAh0RFBscHw/9oACAEBAAE/EBcA9GiRYzRLjtL/2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"OpenVPN in AWS Marketplace\"\n        title=\"\"\n        src=\"/static/dc6ac5c27b83c8abb490e0a59df408d9/326df/awsmarket.jpg\"\n        srcset=\"/static/dc6ac5c27b83c8abb490e0a59df408d9/6f81f/awsmarket.jpg 270w,\n/static/dc6ac5c27b83c8abb490e0a59df408d9/09d21/awsmarket.jpg 540w,\n/static/dc6ac5c27b83c8abb490e0a59df408d9/326df/awsmarket.jpg 1013w\"\n        sizes=\"(max-width: 1013px) 100vw, 1013px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>Click on select button on the first one with the <code class=\"language-text\">free tier eligible</code> badge.</p>\n<h2 id=\"selecting-instance-type\" style=\"position:relative;\"><a href=\"#selecting-instance-type\" aria-label=\"selecting instance type permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Selecting instance type</h2>\n<p>On the next page click continue and select <code class=\"language-text\">t2.micro</code> from instance type list.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 710px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/8a0dd77b5403a96490bb2f7336b5deab/67e9d/instancetype.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 61.11111111111111%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAMABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAEDAgX/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/aAAwDAQACEAMQAAAB6zplEUD/xAAaEAACAgMAAAAAAAAAAAAAAAAAEwIDEBEi/9oACAEBAAEFAlwFwFV430f/xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAZEAACAwEAAAAAAAAAAAAAAAACMgAQkRH/2gAIAQEABj8CQciDkQcrlf/EABoQAAICAwAAAAAAAAAAAAAAAABRAREQgfH/2gAIAQEAAT8h5EbiCQlFUaP/2gAMAwEAAgADAAAAEJ8//8QAFREBAQAAAAAAAAAAAAAAAAAAEBH/2gAIAQMBAT8Qp//EABYRAQEBAAAAAAAAAAAAAAAAAAABEf/aAAgBAgEBPxBlf//EAB0QAQABAwUAAAAAAAAAAAAAAAEAESExQVFhkcH/2gAIAQEAAT8QuwBi7eTBzyxc6EVTqDEts6n/2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Choosing free tier instance type\"\n        title=\"\"\n        src=\"/static/8a0dd77b5403a96490bb2f7336b5deab/67e9d/instancetype.jpg\"\n        srcset=\"/static/8a0dd77b5403a96490bb2f7336b5deab/6f81f/instancetype.jpg 270w,\n/static/8a0dd77b5403a96490bb2f7336b5deab/09d21/instancetype.jpg 540w,\n/static/8a0dd77b5403a96490bb2f7336b5deab/67e9d/instancetype.jpg 710w\"\n        sizes=\"(max-width: 710px) 100vw, 710px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>At this stage click on <em><strong>Review and Launch</strong></em> button.</p>\n<h2 id=\"launch-the-instance\" style=\"position:relative;\"><a href=\"#launch-the-instance\" aria-label=\"launch the instance permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Launch the instance</h2>\n<p>Select general purpose SSD from the pop up and click next. Now click <code class=\"language-text\">Launch</code> and you’ll see a pop up asking you to select a key pair. This is to let you access the instance later on.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 717px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/25da34eb308784196ea93d15cb8f2413/b0abb/keypair.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 75.55555555555556%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAPABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAQAF/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAdpZCI//xAAXEAEBAQEAAAAAAAAAAAAAAAAAERAS/9oACAEBAAEFAo5Ta//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABYQAQEBAAAAAAAAAAAAAAAAABAxAP/aAAgBAQAGPwJup//EABkQAAMBAQEAAAAAAAAAAAAAAAABEfAhUf/aAAgBAQABPyFKRkNfC4hvgiH/2gAMAwEAAgADAAAAEEwf/8QAFREBAQAAAAAAAAAAAAAAAAAAEBH/2gAIAQMBAT8Qp//EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAECAQE/EIf/xAAcEAEBAQABBQAAAAAAAAAAAAABEQAxQVFhgZH/2gAIAQEAAT8QTAD5ilAy0os7YUEAJx0aLtHgw4i+9//Z'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Select a key pair to access the instance\"\n        title=\"\"\n        src=\"/static/25da34eb308784196ea93d15cb8f2413/b0abb/keypair.jpg\"\n        srcset=\"/static/25da34eb308784196ea93d15cb8f2413/6f81f/keypair.jpg 270w,\n/static/25da34eb308784196ea93d15cb8f2413/09d21/keypair.jpg 540w,\n/static/25da34eb308784196ea93d15cb8f2413/b0abb/keypair.jpg 717w\"\n        sizes=\"(max-width: 717px) 100vw, 717px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>Select create a new key pair (or an existing if you already have one), enter a name and click download key pair.</p>\n<p>Save the <code class=\"language-text\">.pem</code> file somewhere safe as this is like a back door to your server 😁. Click Launch Instance and wait for the instance to go to running state.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 699px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/d8f84b50c53a61b35c8bc4e0f92ff116/9149e/status.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 24.814814814814817%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAFABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAdyklB//xAAWEAADAAAAAAAAAAAAAAAAAAAAEBH/2gAIAQEAAQUCKv/EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABQQAQAAAAAAAAAAAAAAAAAAABD/2gAIAQEABj8Cf//EABYQAQEBAAAAAAAAAAAAAAAAABEAEP/aAAgBAQABPyFMN//aAAwDAQACAAMAAAAQiC//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/ED//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAYEAEBAQEBAAAAAAAAAAAAAAABABEhkf/aAAgBAQABPxDSQzyFyGl//9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"status\"\n        title=\"\"\n        src=\"/static/d8f84b50c53a61b35c8bc4e0f92ff116/9149e/status.jpg\"\n        srcset=\"/static/d8f84b50c53a61b35c8bc4e0f92ff116/6f81f/status.jpg 270w,\n/static/d8f84b50c53a61b35c8bc4e0f92ff116/09d21/status.jpg 540w,\n/static/d8f84b50c53a61b35c8bc4e0f92ff116/9149e/status.jpg 699w\"\n        sizes=\"(max-width: 699px) 100vw, 699px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>Click on view instance to see the instance list.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/00cf58adcb2632bf93c3b3d3387c8dc4/f7fe6/instances.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 27.40740740740741%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAFABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB3KAH/8QAFhABAQEAAAAAAAAAAAAAAAAAABEB/9oACAEBAAEFApiI/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFBABAAAAAAAAAAAAAAAAAAAAEP/aAAgBAQAGPwJ//8QAGRAAAgMBAAAAAAAAAAAAAAAAAAERITGB/9oACAEBAAE/IUrKOiJ//9oADAMBAAIAAwAAABDzz//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EABoQAAICAwAAAAAAAAAAAAAAAAABEWFRcZH/2gAIAQEAAT8QSwsKIZ6KW9n/2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Instance list\"\n        title=\"\"\n        src=\"/static/00cf58adcb2632bf93c3b3d3387c8dc4/47311/instances.jpg\"\n        srcset=\"/static/00cf58adcb2632bf93c3b3d3387c8dc4/6f81f/instances.jpg 270w,\n/static/00cf58adcb2632bf93c3b3d3387c8dc4/09d21/instances.jpg 540w,\n/static/00cf58adcb2632bf93c3b3d3387c8dc4/47311/instances.jpg 1080w,\n/static/00cf58adcb2632bf93c3b3d3387c8dc4/f7fe6/instances.jpg 1258w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>Select your instance and click connect.</p>\n<h2 id=\"preparation\" style=\"position:relative;\"><a href=\"#preparation\" aria-label=\"preparation permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Preparation</h2>\n<p>You’ll see a set of instructions on a popup on how to connect to your instance.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 714px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/e72f829022cf1e63b1bf9c8ecbcf827d/ab20e/connect.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 96.66666666666666%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAATABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAECAwX/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/aAAwDAQACEAMQAAAB9u0YaFByCf/EABcQAQEBAQAAAAAAAAAAAAAAAAEQABH/2gAIAQEAAQUC4RK03//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8BH//EABYRAAMAAAAAAAAAAAAAAAAAAAABEP/aAAgBAgEBPwGs/8QAFhAAAwAAAAAAAAAAAAAAAAAAAAEw/9oACAEBAAY/AoM//8QAHBAAAgICAwAAAAAAAAAAAAAAAAEQETFhIUGR/9oACAEBAAE/IQpa8EXiL0NzLN5ds//aAAwDAQACAAMAAAAQUw8D/8QAFxEAAwEAAAAAAAAAAAAAAAAAAAEQMf/aAAgBAwEBPxCrD//EABYRAAMAAAAAAAAAAAAAAAAAAAAQMf/aAAgBAgEBPxB0f//EAB0QAAICAgMBAAAAAAAAAAAAAAERACExkUFRcYH/2gAIAQEAAT8QuSIO4JCqmIU7yuIOxH5HBRFQGhjUfmoUYihDxz//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Instructions on how to connect\"\n        title=\"\"\n        src=\"/static/e72f829022cf1e63b1bf9c8ecbcf827d/ab20e/connect.jpg\"\n        srcset=\"/static/e72f829022cf1e63b1bf9c8ecbcf827d/6f81f/connect.jpg 270w,\n/static/e72f829022cf1e63b1bf9c8ecbcf827d/09d21/connect.jpg 540w,\n/static/e72f829022cf1e63b1bf9c8ecbcf827d/ab20e/connect.jpg 714w\"\n        sizes=\"(max-width: 714px) 100vw, 714px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>In the instruction set they tell you to use <a href=\"https://docs.aws.amazon.com/console/ec2/instances/connect/putty\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">PuTTY</a> to connect to your instance using <code class=\"language-text\">SSH</code>. However, I already have Ubuntu set up in <code class=\"language-text\">WSL</code> (windows subsystem for Linux) and we can use that. Otherwise you can use PuTTY or even the web browser connection.</p>\n<p>Before we do anything we need to set the permissions for our private key 👉🏽 <code class=\"language-text\">.pem</code> 👈🏽 file, otherwise it wouldn’t allow you to connect. If you’re using a Linux or Mac machine, simply run the following command:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"28028039926818570000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`chmod 400 {name-of-file}.pem`, `28028039926818570000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token function\">chmod</span> <span class=\"token number\">400</span> <span class=\"token punctuation\">{</span>name-of-file<span class=\"token punctuation\">}</span>.pem</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>For the rest of you who are like me, right click on the <code class=\"language-text\">.pem</code> file and click <em>Security > Advance</em>. Then change the owner to yourself, click disable inheritance and remove all permissions. Click add and add yourself and give full control.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/8f1d702ac72e1f6753c378b3631c3d3e/35868/permissions.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 65.92592592592594%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAECBf/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAdq0xkB//8QAGBAAAgMAAAAAAAAAAAAAAAAAAAEQERL/2gAIAQEAAQUCYps0f//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABUQAQEAAAAAAAAAAAAAAAAAACBB/9oACAEBAAY/Aqv/xAAdEAABAwUBAAAAAAAAAAAAAAAAARFBEDFRcaHR/9oACAEBAAE/IUTwWe0dcitg0P/aAAwDAQACAAMAAAAQ4A//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/ED//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAdEAEAAwABBQAAAAAAAAAAAAABABEhMVFhobHR/9oACAEBAAE/EGDiys34lq2L3wxx0IA6k6ShftGz9z//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Setting the right permissions for private key\"\n        title=\"\"\n        src=\"/static/8f1d702ac72e1f6753c378b3631c3d3e/47311/permissions.jpg\"\n        srcset=\"/static/8f1d702ac72e1f6753c378b3631c3d3e/6f81f/permissions.jpg 270w,\n/static/8f1d702ac72e1f6753c378b3631c3d3e/09d21/permissions.jpg 540w,\n/static/8f1d702ac72e1f6753c378b3631c3d3e/47311/permissions.jpg 1080w,\n/static/8f1d702ac72e1f6753c378b3631c3d3e/35868/permissions.jpg 1525w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<h2 id=\"connecting\" style=\"position:relative;\"><a href=\"#connecting\" aria-label=\"connecting permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Connecting</h2>\n<p>Once that’s done, open a command prompt, type bash and then enter the following command:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"35805478110547770000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`sudo ssh -i &quot;{name-of-file}.pem&quot; openvpnas@{serveraddress}.compute.amazonaws.com`, `35805478110547770000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token function\">sudo</span> <span class=\"token function\">ssh</span> <span class=\"token parameter variable\">-i</span> <span class=\"token string\">\"{name-of-file}.pem\"</span> openvpnas@<span class=\"token punctuation\">{</span>serveraddress<span class=\"token punctuation\">}</span>.compute.amazonaws.com</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Don’t forget to replace the file name with whatever you’ve chosen previously and replace the name of server with what you got from the instruction popup.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/6973d7e09fca7af87b498dc8fe0153ee/8ab28/connectprompt.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 64.07407407407408%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAECBf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/9oADAMBAAIQAxAAAAHPVQgIP//EABQQAQAAAAAAAAAAAAAAAAAAACD/2gAIAQEAAQUCX//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABQQAQAAAAAAAAAAAAAAAAAAACD/2gAIAQEABj8CX//EABgQAAMBAQAAAAAAAAAAAAAAABAx8AAB/9oACAEBAAE/IZ6Z6x//2gAMAwEAAgADAAAAEFz/AP/EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EABwQAQABBQEBAAAAAAAAAAAAAAEAESFBUZExcf/aAAgBAQABPxCzqFAxVhauvjMyz09lXb2f/9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Connect prompts\"\n        title=\"\"\n        src=\"/static/6973d7e09fca7af87b498dc8fe0153ee/47311/connectprompt.jpg\"\n        srcset=\"/static/6973d7e09fca7af87b498dc8fe0153ee/6f81f/connectprompt.jpg 270w,\n/static/6973d7e09fca7af87b498dc8fe0153ee/09d21/connectprompt.jpg 540w,\n/static/6973d7e09fca7af87b498dc8fe0153ee/47311/connectprompt.jpg 1080w,\n/static/6973d7e09fca7af87b498dc8fe0153ee/0047d/connectprompt.jpg 1620w,\n/static/6973d7e09fca7af87b498dc8fe0153ee/8ab28/connectprompt.jpg 1863w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>Type yes for the agreement, then just hit enter to have all the defaults confirmed. Once you reached to the end, change the password for the user which will be used to login:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"39164572589632815000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`sudo passwd openvpn`, `39164572589632815000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token function\">sudo</span> <span class=\"token function\">passwd</span> openvpn</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Enter a new password twice and you’re all set. Open a browser window and type <code class=\"language-text\">https://{server address}:943/admin</code> and login with <code class=\"language-text\">openvpn</code> and the password you just set.</p>\n<h2 id=\"tidy-up-a-few-settings\" style=\"position:relative;\"><a href=\"#tidy-up-a-few-settings\" aria-label=\"tidy up a few settings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Tidy up a few settings</h2>\n<p>Once in the admin dashboard of OpenVPN, click configuration and apply the following changes:</p>\n<ul>\n<li>Change the toggle for <em>Should client Internet traffic be routed through the VPN?</em> to <strong>Yes</strong></li>\n<li>Change the toggle for <em>Have clients use specific DNS servers</em> to <strong>Yes</strong></li>\n<li>Select custom DNS server and set the first box to <code class=\"language-text\">1.1.1.1</code> (CloudFlare DNS 🦄) and the second to <code class=\"language-text\">8.8.8.8</code></li>\n</ul>\n<p>Now save the settings, wait for the pop up on the top and click apply the changes to server.</p>\n<h2 id=\"youre-good-to-go\" style=\"position:relative;\"><a href=\"#youre-good-to-go\" aria-label=\"youre good to go permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>You’re good to go</h2>\n<p>You’re all set. You can now connect to your very own VPN server and enjoy a private surf of the net 😎. On the first page of the browser window you opened earlier, there are five options to download the OpenVPN client for different platform. If you click on windows, you will get an installer with your server address pre-configured. Just enter your user name and password and voila.</p>\n<p>Hope this will help you if you need a VPN server setup for free.</p>","timeToRead":3,"frontmatter":{"title":"Let's setup a VPN server, for free, on AWS, under 5 min","unformattedDate":"2019-08-21T00:00:00.000Z","date":"Aug 21, 2019","path":"/vpn-aws/","author":"Yaser Adel Mehraban","tags":["showdev","aws","vpn","free"],"thumbnail":null}}},{"node":{"id":"ec7fef18-06af-58ce-90bd-bd0099d9cd61","html":"<p>If you have faced a code like below, then this article will help you in multiple ways 😁.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"72425495295800360000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`fetchPizzas()\r\n  .then((pizzas) =＞ {\r\n    return sortByToppings(pizzas)\r\n      .then((pizzas) =＞ {\r\n        return checkDeliveryOptions(pizzas)\r\n          .then((pizzasWithDelivery) =＞ {\r\n            return checkBirthdayGift(pizzasWithDelivery)\r\n              .then((pizza) =＞ {\r\n                return sendToCustomer(pizza);\r\n              });\r\n          });\r\n      });\r\n  });`, `72425495295800360000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token function\">fetchPizzas</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\r\n  <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span>pizzas<span class=\"token punctuation\">)</span> <span class=\"token operator\">=</span>＞ <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">return</span> <span class=\"token function\">sortByToppings</span><span class=\"token punctuation\">(</span>pizzas<span class=\"token punctuation\">)</span>\r\n      <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span>pizzas<span class=\"token punctuation\">)</span> <span class=\"token operator\">=</span>＞ <span class=\"token punctuation\">{</span>\r\n        <span class=\"token keyword\">return</span> <span class=\"token function\">checkDeliveryOptions</span><span class=\"token punctuation\">(</span>pizzas<span class=\"token punctuation\">)</span>\r\n          <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span>pizzasWithDelivery<span class=\"token punctuation\">)</span> <span class=\"token operator\">=</span>＞ <span class=\"token punctuation\">{</span>\r\n            <span class=\"token keyword\">return</span> <span class=\"token function\">checkBirthdayGift</span><span class=\"token punctuation\">(</span>pizzasWithDelivery<span class=\"token punctuation\">)</span>\r\n              <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span>pizza<span class=\"token punctuation\">)</span> <span class=\"token operator\">=</span>＞ <span class=\"token punctuation\">{</span>\r\n                <span class=\"token keyword\">return</span> <span class=\"token function\">sendToCustomer</span><span class=\"token punctuation\">(</span>pizza<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n              <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n          <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<!--more-->\n<h2 id=\"a-little-bit-of-background\" style=\"position:relative;\"><a href=\"#a-little-bit-of-background\" aria-label=\"a little bit of background permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>A little bit of background</h2>\n<p>There are many a times where we have a bunch of tasks to be executed sequentially. The examples are from File handling to calling databases multiple times based on the result of the previous call. Or calling multiple APIs in a sequence where one call is dependenat on another.</p>\n<p>Prior to introduction of <code class=\"language-text\">async/await</code>, many used callbacks alongside <code class=\"language-text\">setTimeOut</code> to simulated the behaviour they wanted (aka callback hell). Later on people started to use promises which made the code much more readable but they would end up in the same place when the number of calls where high (aka promise hell).</p>\n<h2 id=\"async-functions\" style=\"position:relative;\"><a href=\"#async-functions\" aria-label=\"async functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Async functions</h2>\n<p>A function in JavaScript is <code class=\"language-text\">async</code> when it operates asynchronously via the event loop, using an implicit promise to return its result. Furthermore, the type of its result should be an <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><code class=\"language-text\">AsyncFuncton</code></a> object.</p>\n<p>This function is nothing but a combination of <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">promises</a> and <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#Generator_functions\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">generators</a>. I will not going into details of generators, but they usually contains one or many <code class=\"language-text\">yield</code> keywords.</p>\n<p>Now lets see the <code class=\"language-text\">async</code> function in action. Assume we have a function which returns a string:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"62845051756466240000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`function hi() {\r\n  return 'Hi from JavaScript';\r\n}\r\n\r\nhi(); // 'Hi from JavaScript'`, `62845051756466240000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">function</span> <span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">return</span> <span class=\"token string\">'Hi from JavaScript'</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span>\r\n\r\n<span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// 'Hi from JavaScript'</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>If we put <code class=\"language-text\">async</code> in front of the function, then it no longer returns string, it will be a promise which is wrapped around the string value automatically.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"1990772624099457300\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`async function hi() {\r\n  return 'Hi from JavaScript';\r\n}\r\n\r\nhi(); // Promise {<resolved>: &quot;Hi from JavaScript&quot;}`, `1990772624099457300`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span> <span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">return</span> <span class=\"token string\">'Hi from JavaScript'</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span>\r\n\r\n<span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// Promise {&lt;resolved>: \"Hi from JavaScript\"}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Now in order to get the value from the promise we act like before:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"92347541897150790000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`hi().then(console.log); // 'Hi from JavaScript'`, `92347541897150790000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span>console<span class=\"token punctuation\">.</span>log<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// 'Hi from JavaScript'</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>You might be wondering how this can help to solve the promise hell. Just bare with me and we’ll get there step by step with examples so it’d be clear when we’re finished.</p>\n<h2 id=\"await\" style=\"position:relative;\"><a href=\"#await\" aria-label=\"await permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Await</h2>\n<p>The <code class=\"language-text\">await</code> makes JavaScript engine to wait until a promise is resolved/rejected and returns it’s result. This keyword can only be used inside an <code class=\"language-text\">async</code> function.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"31810125341723492000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const doSomething = async () => {\r\n  console.log(await hi())\r\n};\r\n\r\n// 'Hi from JavaScript'`, `31810125341723492000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">const</span> <span class=\"token function-variable function\">doSomething</span> <span class=\"token operator\">=</span> <span class=\"token keyword\">async</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">await</span> <span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token comment\">// 'Hi from JavaScript'</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>You might think since <code class=\"language-text\">await</code> forces the JavaScript engine to wait, it will have some cost on CPU. But that’s not the case because the engine can perform other scripts while waiting for the promise to get resolves/rejected. Plus this is way more elegant that using <code class=\"language-text\">promises</code> and <code class=\"language-text\">.then</code>.</p>\n<div class=\"custom-block warning\"><div class=\"custom-block-body\"><strong>Warning:</strong> If you try to invoke an <code class=\"language-text\">async</code> function using <code class=\"language-text\">await</code> inside a normal function, you will get a syntax error.</div></div>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"41520687732957870000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`function doSomething() {\r\n  await hi(); // Uncaught SyntaxError: await is only valid in async function\r\n}`, `41520687732957870000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">function</span> <span class=\"token function\">doSomething</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">await</span> <span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// Uncaught SyntaxError: await is only valid in async function</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"a-small-catch\" style=\"position:relative;\"><a href=\"#a-small-catch\" aria-label=\"a small catch permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>A small catch</h2>\n<p>Most people who start working with <code class=\"language-text\">async/await</code> forget that they can’t invoke an <code class=\"language-text\">async</code> function on top level code. This is due to the fact that we can’t have <code class=\"language-text\">await</code> inside a normal function and the top level functions are normal by default.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"84264427755186520000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`let response = await hi(); // syntax error in top-level code\r\nconsole.log(response);`, `84264427755186520000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">let</span> response <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> <span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// syntax error in top-level code</span>\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>response<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>What you can do however, is to wrap your code in an <code class=\"language-text\">async</code> <code class=\"language-text\">IIFE</code> (immediately invoked function execution) and call it right there:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"33333336220037337000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`(async () => {\r\n  let response = await hi(); \r\n  console.log(response); // 'Hi from JavaScript'\r\n  ...\r\n})();`, `33333336220037337000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token punctuation\">(</span><span class=\"token keyword\">async</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">let</span> response <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> <span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> \r\n  console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>response<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// 'Hi from JavaScript'</span>\r\n  <span class=\"token operator\">...</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"error-handling\" style=\"position:relative;\"><a href=\"#error-handling\" aria-label=\"error handling permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Error handling</h2>\n<p>As I said before, most <code class=\"language-text\">async</code> functions can be written as a normal function with promises. However, <code class=\"language-text\">async</code> functions are less <code class=\"language-text\">error-prone</code> when it comes to error handling. If an awaited call fails, the exception is automatically caught and the <code class=\"language-text\">Error</code> object will be propagated to the caller using the implicit return promise.</p>\n<p>Prior to this, we had to reject the promise which was returned from the normal function and use a <code class=\"language-text\">.catch</code> in the caller. I’ve seen many places where the developers used a try/catch and throw a new exception which meant the stack trace would be reset.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"41724323118056650000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`async function hi() {\r\n  throw new Error(&quot;Whoops!&quot;);\r\n};\r\n\r\nasync function doSomething() {\r\n\r\n  try {\r\n    let response = await hi();\r\n    return response;\r\n  } catch(err) {    \r\n    console.log(err);\r\n  }\r\n}\r\n\r\ndoSomething();`, `41724323118056650000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span> <span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">throw</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Error</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"Whoops!\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span> <span class=\"token function\">doSomething</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n\r\n  <span class=\"token keyword\">try</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">let</span> response <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> <span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token keyword\">return</span> response<span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span> <span class=\"token keyword\">catch</span><span class=\"token punctuation\">(</span>err<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>    \r\n    console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>err<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span>\r\n\r\n<span class=\"token function\">doSomething</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Or you can avoid the <code class=\"language-text\">try/catch</code> because the promise generated by the call to <code class=\"language-text\">hi</code> becomes rejected. Then simply use <code class=\"language-text\">.catch</code> to handle the error.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"28782003660247700000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`async function hi() {\r\n  throw new Error(&quot;Whoops!&quot;);\r\n};\r\n\r\nasync function doSomething() {\r\n  let response = await hi();\r\n  return response;\r\n}\r\n\r\ndoSomething().catch(err => {\r\n  console.log(err);\r\n});`, `28782003660247700000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span> <span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">throw</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Error</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"Whoops!\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span> <span class=\"token function\">doSomething</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">let</span> response <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> <span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token keyword\">return</span> response<span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span>\r\n\r\n<span class=\"token function\">doSomething</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">catch</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">err</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>err<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>You can ignore the catch all together and handle all the exceptions using a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onrejectionhandled\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">global exception handler</a> if you think that’s more suitable to your situation. Something like this which uses the <code class=\"language-text\">onrejectionhandled</code> property of <code class=\"language-text\">WindowsEventHandlers</code> mixin.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"80533241356297420000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`window.onrejectionhandled = function(e) {\r\n  console.log(e.reason);\r\n}`, `80533241356297420000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">window<span class=\"token punctuation\">.</span><span class=\"token function-variable function\">onrejectionhandled</span> <span class=\"token operator\">=</span> <span class=\"token keyword\">function</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">e</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>e<span class=\"token punctuation\">.</span>reason<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"promiseall-compatibility\" style=\"position:relative;\"><a href=\"#promiseall-compatibility\" aria-label=\"promiseall compatibility permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Promise.all compatibility</h2>\n<p>You can use <code class=\"language-text\">async/await</code> alongside <code class=\"language-text\">Promise.all</code> to wait for multiple promises:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"552291000600591000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const responses = await Promise.all([\r\n  fetch('yashints.dev/rss'),\r\n  hi(),\r\n  ...\r\n])`, `552291000600591000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">const</span> responses <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> Promise<span class=\"token punctuation\">.</span><span class=\"token function\">all</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span>\r\n  <span class=\"token function\">fetch</span><span class=\"token punctuation\">(</span><span class=\"token string\">'yashints.dev/rss'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token function\">hi</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token operator\">...</span>\r\n<span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>If an error occurs, it propagates as usual, from the failed promise to <code class=\"language-text\">Promise.all</code> and then turns to an exception that you can catch using any of the above methods.</p>\n<h2 id=\"code-classlanguage-textawaitcode-can-take-in-a-thenable\" style=\"position:relative;\"><a href=\"#code-classlanguage-textawaitcode-can-take-in-a-thenable\" aria-label=\"code classlanguage textawaitcode can take in a thenable permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">await</code> can take in a “thenable”</h2>\n<p>Similar to <code class=\"language-text\">promise.then</code>, if you have any object which has a <code class=\"language-text\">.then</code> method, <code class=\"language-text\">await</code> will accepts it. This is to support scenarios where a 3rd-party object which is not a promise, but promise-compatible (it supports <code class=\"language-text\">.then</code>), it would be enough to use it with <code class=\"language-text\">await</code>.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"85944593850480050000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`class Greeting {\r\n  constructor(name) {\r\n    this.name = name;\r\n  }\r\n\r\n  then(resolve, reject) {\r\n    console.log(resolve);\r\n\r\n    setTimeout(() => resolve(\\`Hi \\${this.name}\\`));\r\n  }\r\n};\r\n\r\nasync function greet() {\r\n  const greeting = await Greeting('Yaser');\r\n\r\n  console.log(greeting); // Hi Yaser\r\n};\r\n\r\ngreet();`, `85944593850480050000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">class</span> <span class=\"token class-name\">Greeting</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token function\">constructor</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">name</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">this</span><span class=\"token punctuation\">.</span>name <span class=\"token operator\">=</span> name<span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span>\r\n\r\n  <span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">resolve<span class=\"token punctuation\">,</span> reject</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n    console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>resolve<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n    <span class=\"token function\">setTimeout</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token function\">resolve</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Hi </span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span><span class=\"token keyword\">this</span><span class=\"token punctuation\">.</span>name<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span> <span class=\"token function\">greet</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">const</span> greeting <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> <span class=\"token function\">Greeting</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Yaser'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n  console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>greeting<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// Hi Yaser</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token function\">greet</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"code-classlanguage-textasynccode-class-methods\" style=\"position:relative;\"><a href=\"#code-classlanguage-textasynccode-class-methods\" aria-label=\"code classlanguage textasynccode class methods permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">async</code> class methods</h2>\n<p>You can have an <code class=\"language-text\">async</code> class method. Just prepend it with <code class=\"language-text\">async</code> and you’re good to go.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"49291737529517060000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`class Order {\r\n  async deliver() {\r\n    return await Promise.resolve('Pizza');\r\n  }\r\n}\r\n\r\nnew Order()\r\n  .delivery()\r\n  .then(console.log); // Pizza`, `49291737529517060000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">class</span> <span class=\"token class-name\">Order</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">async</span> <span class=\"token function\">deliver</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">return</span> <span class=\"token keyword\">await</span> Promise<span class=\"token punctuation\">.</span><span class=\"token function\">resolve</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Pizza'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span>\r\n\r\n<span class=\"token keyword\">new</span> <span class=\"token class-name\">Order</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\r\n  <span class=\"token punctuation\">.</span><span class=\"token function\">delivery</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\r\n  <span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span>console<span class=\"token punctuation\">.</span>log<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// Pizza</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>Just to quickly go through what we discussed so far:</p>\n<ol>\n<li><code class=\"language-text\">async</code> keyword makes a method asynchronous, which in turn always returns a promise and allows <code class=\"language-text\">await</code> to be used.</li>\n<li><code class=\"language-text\">await</code> keyword before a promise makes JavaScript wait until that is resolved/rejected. If the promise is rejected, an exception is generated, otherwise the result is returned.</li>\n<li>Together, they provide a great opportunity for us to write clean, more testable, asynchronous code.</li>\n<li>With <code class=\"language-text\">async/await</code> you wouldn’t need <code class=\"language-text\">.then/.catch</code>, but just note that they are still based on promises.</li>\n<li>You can use <code class=\"language-text\">Promise.all</code> to wait for multiple <code class=\"language-text\">async</code> functions calls.</li>\n<li>You can have an <code class=\"language-text\">async</code> method in a class.</li>\n</ol>\n<p>I know there are many great articles around <code class=\"language-text\">async/await</code>, but I tried to cover some items where I had to constantly remind myself of. Hope it will help you to have a centralised place for most of what you need to write clean asynchronous JavaScript.</p>\n<p>Have fun exploring these points.</p>","timeToRead":4,"frontmatter":{"title":"6 points you need to know about async & await in JavaScript","unformattedDate":"2019-08-17T00:00:00.000Z","date":"Aug 17, 2019","path":"/js-async-await/","author":"Yaser Adel Mehraban","tags":["showdev","webdev","async","await"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAKABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAMF/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/9oADAMBAAIQAxAAAAHKrFkFf//EABgQAAIDAAAAAAAAAAAAAAAAAAECABEg/9oACAEBAAEFAgLjKM//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAVEQEBAAAAAAAAAAAAAAAAAAAQEf/aAAgBAgEBPwGH/8QAGBAAAgMAAAAAAAAAAAAAAAAAAAESILH/2gAIAQEABj8CFHa//8QAGxAAAQQDAAAAAAAAAAAAAAAAAQARIUEgMYH/2gAIAQEAAT8hJo3SjaYl7Y//2gAMAwEAAgADAAAAENQv/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPxA//8QAFhEBAQEAAAAAAAAAAAAAAAAAAREQ/9oACAECAQE/EFLbn//EABsQAQEAAQUAAAAAAAAAAAAAAAERACBBUXGx/9oACAEBAAE/EBGjOA9xBAASdu560//Z"},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/fb3883e15852de11a094b8a6a3d8aee8/52fd2/asyncawaitjs.jpg","srcSet":"/static/fb3883e15852de11a094b8a6a3d8aee8/c93cd/asyncawaitjs.jpg 750w,\n/static/fb3883e15852de11a094b8a6a3d8aee8/c41e3/asyncawaitjs.jpg 1080w,\n/static/fb3883e15852de11a094b8a6a3d8aee8/52fd2/asyncawaitjs.jpg 1200w","sizes":"(min-width: 1200px) 1200px, 100vw"},"sources":[{"srcSet":"/static/fb3883e15852de11a094b8a6a3d8aee8/11ba1/asyncawaitjs.webp 750w,\n/static/fb3883e15852de11a094b8a6a3d8aee8/089e1/asyncawaitjs.webp 1080w,\n/static/fb3883e15852de11a094b8a6a3d8aee8/823ad/asyncawaitjs.webp 1200w","type":"image/webp","sizes":"(min-width: 1200px) 1200px, 100vw"}]},"width":1200,"height":600}}}}}},{"node":{"id":"216f119b-1511-59ea-b804-655c3b9b17e9","html":"<p>It’s been a while since one of the X can do that posts I’ve been publishing. Furthermore, <a href=\"https://developer.mozilla.org/en-US/docs/Tools\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Firefox Developer tools</a> is just getting better and better everyday, so I thought it’s about time I write one for it.</p>\n<p>So, are you ready? 😎</p>\n<!--more-->\n<h2 id=\"how-to-open-it\" style=\"position:relative;\"><a href=\"#how-to-open-it\" aria-label=\"how to open it permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How to open it</h2>\n<p>You can open the <em>Firefox Developer Tools</em> from the menu by selecting <em>Tools</em> > <em>Web Developer</em> > <em>Toggle Tools</em> or use the keyboard shortcut <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>I</kbd> or <kbd>F12</kbd> on Windows and Linux, or <kbd>Cmd</kbd> + <kbd>Opt</kbd> + <kbd>I</kbd> on macOS.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 225px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/7e201c1dea64888838c1bfc2a1f0fa5b/3684f/menu.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 128.88888888888889%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAaCAIAAAA44esqAAAACXBIWXMAAAsTAAALEwEAmpwYAAADSUlEQVR42n1UaVPjOBDN//8ZMF+omk+7FLCzGagaSG0xkMM5vImP+Iwdx/GpOLbla57tJARmly7RtBw99dPrljqE7MLws7HdOkEQBgFxHNe2HUnRNd0EareLOpRmWZa340NcFKXvB93ud8Mwq6q6ubldSvLzS3++ECRJFsVlJ44TQqJmpz1ieMQkrMeORJ7nr1aG4zjIo2n62rJlRVO1VRiSOjP+sIpSCrRhGPBpmoJARmvD/6Io8rxIkxTTOI4xxQKA05R2mjOH2FtV1YuLC3Y24xaLOTubc7wkLtnZdDAYTCdTx/HAvCxLeOABBs1OFO1h2Aw5X19focyOELDFjiQMfd93HddaW/t9fA5Gyjoz9AQZfFIUpdvt8hyHMxk6JDVc19U1lVtw0K86s2PmtJM0hk9gfn9/b9sbZ7td6dDGQm2WgsAt+JR+BIMsPEpFW7Asy4+Pj7qmmaZpWxtzbXm+L8vS+WlP4BbyBtY0rdfrmYahqYrI8yp4G6vZbOZ+Akap2giCPTw8rNcmyh2hftArIKgPNLM3GxJFJzzATUVpDW4F4zju6upqu9mMx8Pe0z+D/oBhJqIkjoejYb/P8QLNixP4oDbAsDxHP1IUDAF+K0uMgzv4ssyOhmWENE2C6EQbyfG1LUzZZMBep2ztFLvAgyyCN8Gm0+nF5SWaixmNBsOhokhPT0/MaCLw/GTMvPz8ifsQhgEakWb5QbA4XSQpQYQ5z/PwWZ4nMXzWcEvRgsjT6to2NjIfwZRNkgCRaRqXX74gITPq//jRYxhGWEq/FSk3Vjo9gf+6vbVtGxG2lyQJ3ve9IAgstIpt1yfM8vZiNUfO26vWFqjDT2PfQ6/lB52Qp2zkquOqlSc7M0zB/AAW/qUkTBGFrgOejrM1jRXuhqJq0lLUdT1JaPXe3jrsxYz9qI72O6KoilybJKAnltJ8zqJPN7Zzdur34OdV7DVglDskZI+OITtcGs9xQbL6L3sDi+yBdryPBH7B4u0YT1mWfXl+FkUJ6z4D85PUMvESJWGQei4Ki9bJ2iY9PmQfDUi8QTX472+3d3d/3t39gXF9/dXajNKM38c2Wheq0v+xllEH709VqcehlZVaVMuiDBqCZfWp/QIYWbwnut/aIwAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Firefox Developer Tools menu\"\n        title=\"\"\n        src=\"/static/7e201c1dea64888838c1bfc2a1f0fa5b/3684f/menu.png\"\n        srcset=\"/static/7e201c1dea64888838c1bfc2a1f0fa5b/3684f/menu.png 225w\"\n        sizes=\"(max-width: 225px) 100vw, 225px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<h2 id=\"page-inspector\" style=\"position:relative;\"><a href=\"#page-inspector\" aria-label=\"page inspector permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Page Inspector</h2>\n<p>There are many useful features in the page inspector (equivalent to Chrome DevTools inspect element), but there are a few which I use the most:</p>\n<h3 id=\"search-for-css-classes\" style=\"position:relative;\"><a href=\"#search-for-css-classes\" aria-label=\"search for css classes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Search for CSS classes</h3>\n<p>You can use the search box right below the inspector tab to search for elements, classes and other selectors. But I mostly use it to search for elements with a specific class. This is very useful if you have multiple elements which visually look similar but have specific class, or if you can’t see it because it is hidden.</p>\n<p><img src=\"/b874d25602de8b85fb5d72d8944e9c9c/css-class-search.gif\" alt=\"CSS class search box\"></p>\n<h3 id=\"filter-styles\" style=\"position:relative;\"><a href=\"#filter-styles\" aria-label=\"filter styles permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Filter styles</h3>\n<p>In the section below, there is box for filtering styles which can be used to easily spot a particular style you might be looking for. The good thing is, it highlights the selectors and expands properties which lets you easily spot what you’re looking for.</p>\n<p><img src=\"/f5a3d6740361ac6d084301c7db987782/style-filter.gif\" alt=\"Search for styles in filter box\"></p>\n<h3 id=\"see-colour-codes-in-different-formats\" style=\"position:relative;\"><a href=\"#see-colour-codes-in-different-formats\" aria-label=\"see colour codes in different formats permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>See colour codes in different formats</h3>\n<p>One of my favourites is this little nugget of gold. With this you can easily <kbd>Shift</kbd> + <kbd>click</kbd> and see all different types of colour representation including <code class=\"language-text\">name</code>, <code class=\"language-text\">hex</code>, <code class=\"language-text\">rgb</code>, and <code class=\"language-text\">hsl</code>. Of course not all colours have names, you in some cases you only see the other ones.</p>\n<p><img src=\"/519a544dca2564e2c5891ef89f254bbd/colourrep.gif\" alt=\"Colour representation\"></p>\n<p>Cool hah?</p>\n<h2 id=\"web-console\" style=\"position:relative;\"><a href=\"#web-console\" aria-label=\"web console permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Web Console</h2>\n<p>Who doesn’t love the console in the browsers’s developer tools. It’s used for logging, calculation, evaluation and much more.</p>\n<h3 id=\"styling-console-messages\" style=\"position:relative;\"><a href=\"#styling-console-messages\" aria-label=\"styling console messages permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Styling console messages</h3>\n<p>You can get fancy with the messages in the console by applying CSS styles to them. This becomes important when you have heaps of logs and want to highlight a specific part by a different style for example.</p>\n<p><img src=\"/c98852ac8be49189f2a44d6f1ac3bb27/console-style.gif\" alt=\"Adding styles to console messages\"></p>\n<p>Note that you already have <code class=\"language-text\">console.info</code>, <code class=\"language-text\">console.warn</code> and <code class=\"language-text\">console.error</code> at your disposal. So this will be a level above what you can get with those.</p>\n<p><img src=\"/96fb71566bd9667b5a1ae0a9705c97da/console-msg.jpg\" alt=\"console info, warning and error messages\"></p>\n<h3 id=\"search-in-history-of-commands\" style=\"position:relative;\"><a href=\"#search-in-history-of-commands\" aria-label=\"search in history of commands permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Search in history of commands</h3>\n<p>This one is helpful if you have typed many commands and want to search between those commands. Simply type all or part of the command you’re looking for and it shows you all that matches that phrase.</p>\n<p>Press <kbd>F9</kbd> on windows or <kbd>CTRL</kbd> + <kbd>R</kbd> to open the search box. Then type your term and if the count on the right hand side shows you have results, you can move between those by pressing the <kbd>F9</kbd> and <kbd>SHIFT</kbd> + <kbd>F9</kbd> on windows. For Mac users, navigate between those using <kbd>CTRL</kbd> + <kbd>R</kbd> and <kbd>CTRL</kbd> + <kbd>S</kbd>.</p>\n<p><img src=\"/8efaad5bf616d8af11a6d08a4756be07/console-search.gif\" alt=\"search in console history\"></p>\n<p>PS: I am just using arrow keys because <kbd>F9</kbd> is mapped to pause and play on my recording software and I am just too lazy to change that 😁.</p>\n<h3 id=\"screenshot-of-the-whole-page\" style=\"position:relative;\"><a href=\"#screenshot-of-the-whole-page\" aria-label=\"screenshot of the whole page permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Screenshot of the whole page</h3>\n<p>To get a screen shot of the whole page, view port, or just an element, all you need to do is type <code class=\"language-text\">:screenshot</code> and pass the parameter you like. Combinations are:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"68813552791586275000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`:screenshot                           //the visible part of the page\r\n:screenshot --fullpage                // whole page even invisible parts\r\n:screenshot --selector .css-selector  // only one element (including its children)`, `68813552791586275000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\">:screenshot                           //the visible part of the page\r\n:screenshot <span class=\"token parameter variable\">--fullpage</span>                // whole page even invisible parts\r\n:screenshot <span class=\"token parameter variable\">--selector</span> .css-selector  // only one element <span class=\"token punctuation\">(</span>including its children<span class=\"token punctuation\">)</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p><img src=\"/98703d3a1343cc27253858545f50356e/screenshot.gif\" alt=\"taking a screenshot\"></p>\n<p>Find out more about other parameters you can pass to it <a href=\"https://developer.mozilla.org/en-US/docs/Tools/Taking_screenshots#Taking_screenshots_with_the_web_console\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">in the documentation</a>.</p>\n<p>And of course you can take the screenshots using photo icon on the left side of the console in the above picture too.</p>\n<h2 id=\"javascript-debugger\" style=\"position:relative;\"><a href=\"#javascript-debugger\" aria-label=\"javascript debugger permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>JavaScript debugger</h2>\n<p>Apart from the above two sections, like any other developer tools, is the debugger section where you could look into source code to see why something is happening the way it shouldn’t or just simply test out something.</p>\n<h3 id=\"pretty-print-minified-code\" style=\"position:relative;\"><a href=\"#pretty-print-minified-code\" aria-label=\"pretty print minified code permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Pretty print minified code</h3>\n<p>To prettify a minified file, click this icon: <code class=\"language-text\">{}</code> in the source pane. The debugger will format the source and display it as a new file with a name like: ”{ } [original-name]“.</p>\n<p><img src=\"/612c8fa42b081fefac862d958bae7769/pretty-print.gif\" alt=\"Pretty print minified code\"></p>\n<h3 id=\"search-for-filesfunctions\" style=\"position:relative;\"><a href=\"#search-for-filesfunctions\" aria-label=\"search for filesfunctions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Search for files/functions</h3>\n<p>To search for a specific file, simply press <kbd>CTRL</kbd> + <kbd>P</kbd> (or <kbd>CMD</kbd> + <kbd>P</kbd> on a Mac). The display panel shows a list of files matching the search term as you type which you can choose. Just press <kbd>Enter</kbd> to open the file.</p>\n<p><img src=\"/d896579b21ae48757fc069fe487aadcf/search-file.gif\" alt=\"Searching for a file\"></p>\n<h3 id=\"xhr-xmlhttprequest-breakpoint\" style=\"position:relative;\"><a href=\"#xhr-xmlhttprequest-breakpoint\" aria-label=\"xhr xmlhttprequest breakpoint permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>XHR (XMLHttpRequest) breakpoint</h3>\n<p>Sometimes you need to figure out what happens when you visit/send a request to a particular URL. Once set and the URL is hit, the execution will stop so you can see the state of the application at that point.</p>\n<p>Just click on the <kbd>+</kbd> in the XHR breakpoint section or if you want to enable it for all URLs, just tick the ‘Pause on any URL’ checkbox.</p>\n<p><img src=\"/4bfcdd2487eb43d6146affb30b178147/urlbreakpoint.gif\" alt=\"URL breakpoint\"></p>\n<h2 id=\"performance-tool\" style=\"position:relative;\"><a href=\"#performance-tool\" aria-label=\"performance tool permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Performance tool</h2>\n<p>The performance tool is where I usually spending most of my time in. As you might know, I’ve been actively working on web performance and also have a <a href=\"https://dev.to/yashints/improve-html-and-css-performance-4o08\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">series of posts</a> on some important aspects of it.</p>\n<p>However for the purpose of keeping this post short (pardon the pun 😁), I will only point to two of the ones I regularly use. You can find out more about the rest in <a href=\"https://developer.mozilla.org/en-US/docs/Tools/Performance\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">the official docs</a>.</p>\n<h3 id=\"waterfall-tab\" style=\"position:relative;\"><a href=\"#waterfall-tab\" aria-label=\"waterfall tab permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Waterfall tab</h3>\n<p>Before you get to see these tabs, you should record a page’s load by pressing the ⏱ icon. Once it’s done, you will see the waterfall tab by default. Along the <code class=\"language-text\">X</code> axis is time.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/3b8a6a63aa08aadf6d97da5d75f3261e/d2757/waterfall.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 44.074074074074076%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAJABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAUBAv/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/9oADAMBAAIQAxAAAAHibUlmiz//xAAYEAADAQEAAAAAAAAAAAAAAAABBBAAAv/aAAgBAQABBQJwHmvYT//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABkQAAIDAQAAAAAAAAAAAAAAAAEQAgMicf/aAAgBAQAGPwKGieut/wD/xAAbEAACAgMBAAAAAAAAAAAAAAABEQAQITFxwf/aAAgBAQABPyFbLr4gyK95oK//2gAMAwEAAgADAAAAEEgf/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPxA//8QAFREBAQAAAAAAAAAAAAAAAAAAARD/2gAIAQIBAT8QJ//EAB8QAQACAQMFAAAAAAAAAAAAAAEAEVEQITFhcZGhwf/aAAgBAQABPxBzoGcNiiKlQusQDB4nPs+Z6Wn/2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"waterfall tab in performance view of Firefox developer tools\"\n        title=\"\"\n        src=\"/static/3b8a6a63aa08aadf6d97da5d75f3261e/47311/waterfall.jpg\"\n        srcset=\"/static/3b8a6a63aa08aadf6d97da5d75f3261e/6f81f/waterfall.jpg 270w,\n/static/3b8a6a63aa08aadf6d97da5d75f3261e/09d21/waterfall.jpg 540w,\n/static/3b8a6a63aa08aadf6d97da5d75f3261e/47311/waterfall.jpg 1080w,\n/static/3b8a6a63aa08aadf6d97da5d75f3261e/0047d/waterfall.jpg 1620w,\n/static/3b8a6a63aa08aadf6d97da5d75f3261e/274e1/waterfall.jpg 2160w,\n/static/3b8a6a63aa08aadf6d97da5d75f3261e/d2757/waterfall.jpg 2701w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>As you can see, all sorts of the stuff which browser has done such as running JavaScript, updating layout, garbage collection, and so on is shown in the view. You can find out how your application is performing on load and what type of things take the most time to finish easily in this view.</p>\n<p>The good thing is that each category is coloured differently so you can spot them easily in each category.</p>\n<p>For a full reference of what each colour represents, refer to the <a href=\"https://developer.mozilla.org/en-US/docs/Tools/Performance/Waterfall#Markers\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">markers table on the docs</a>.</p>\n<h3 id=\"call-tree\" style=\"position:relative;\"><a href=\"#call-tree\" aria-label=\"call tree permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Call tree</h3>\n<p>You can see a call tree of all the functions which has been called from top to bottom in this view. The main purpose of this view is to show you which function has taken the most time executing. By analysing these calls, you can find bottlenecks in your code.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/020af17329c63d208ed09d98ddd7bea8/b4088/calltree.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 54.074074074074076%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAALABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAIBAwX/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/aAAwDAQACEAMQAAABynSyyAD/xAAZEAACAwEAAAAAAAAAAAAAAAAAAQIQETH/2gAIAQEAAQUCRhiI8r//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAUEAEAAAAAAAAAAAAAAAAAAAAg/9oACAEBAAY/Al//xAAaEAACAgMAAAAAAAAAAAAAAAAAARARITFR/9oACAEBAAE/Ic02U5BuKRR//9oADAMBAAIAAwAAABDsH//EABURAQEAAAAAAAAAAAAAAAAAAAEQ/9oACAEDAQE/EGf/xAAWEQEBAQAAAAAAAAAAAAAAAAAAIQH/2gAIAQIBAT8Qyo//xAAdEAEAAgEFAQAAAAAAAAAAAAABABGhITFBUWGR/9oACAEBAAE/EGsAt8BBi3CeR8mZNLbMp1P/2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"call tree\"\n        title=\"\"\n        src=\"/static/020af17329c63d208ed09d98ddd7bea8/47311/calltree.jpg\"\n        srcset=\"/static/020af17329c63d208ed09d98ddd7bea8/6f81f/calltree.jpg 270w,\n/static/020af17329c63d208ed09d98ddd7bea8/09d21/calltree.jpg 540w,\n/static/020af17329c63d208ed09d98ddd7bea8/47311/calltree.jpg 1080w,\n/static/020af17329c63d208ed09d98ddd7bea8/0047d/calltree.jpg 1620w,\n/static/020af17329c63d208ed09d98ddd7bea8/b4088/calltree.jpg 2143w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>You can see in the result table that each row represents one function and the order is highest to lowest by the number of samples which has been taken while the function was executing. From docos:</p>\n<blockquote>\n<p><em>Total Time</em> is that number translated into milliseconds, based on the total amount of time covered by the selected portion of the recording. These numbers should roughly be the same as the number of samples.<br>\n<em>Total Cost</em> is that number as a percentage of the total number of samples in the selected portion of the recording.<br>\n<em>Self Time</em> is calculated as the time spent in that particular function, excluding its children. This comes from the captured stacks where this function is the leafmost function.<br>\n<em>Self Cost</em> is calculated from Self Time as a percentage of the total number of samples in the selected portion of the recording.</p>\n</blockquote>\n<h2 id=\"miscellaneous\" style=\"position:relative;\"><a href=\"#miscellaneous\" aria-label=\"miscellaneous permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Miscellaneous</h2>\n<p>There are heaps of other stuff which is outside of scope of a single post. But I want to point out a few of the other useful things you can do with Firefox Developer Tools.</p>\n<h3 id=\"accessibility-inspector\" style=\"position:relative;\"><a href=\"#accessibility-inspector\" aria-label=\"accessibility inspector permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Accessibility Inspector</h3>\n<p>The <strong>Accessibility Inspector</strong> allows you to access important information exposed to assistive technologies on the current page via the accessibility tree, which lets you to check what’s missing or needs improvements.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/853d434b15fecc13a6b2bbb64bfee1b4/06565/accessibility.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 43.7037037037037%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAJABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAIGBAX/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAHVwKObFGD/xAAZEAACAwEAAAAAAAAAAAAAAAAEEAIDETT/2gAIAQEAAQUCKjlCM5l//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFhABAQEAAAAAAAAAAAAAAAAAARBx/9oACAEBAAY/Amu3/8QAHRAAAQIHAAAAAAAAAAAAAAAAAAFBEBEhYYGhsf/aAAgBAQABPyFp1VGJWMGo7H//2gAMAwEAAgADAAAAELjv/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPxA//8QAFREBAQAAAAAAAAAAAAAAAAAAEBH/2gAIAQIBAT8Qp//EABwQAQABBAMAAAAAAAAAAAAAAAEAESExURBh8P/aAAgBAQABPxAltWGApfqbosRGuU83SGeP/9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Accessibility panel in Firefox Developer tools\"\n        title=\"\"\n        src=\"/static/853d434b15fecc13a6b2bbb64bfee1b4/47311/accessibility.jpg\"\n        srcset=\"/static/853d434b15fecc13a6b2bbb64bfee1b4/6f81f/accessibility.jpg 270w,\n/static/853d434b15fecc13a6b2bbb64bfee1b4/09d21/accessibility.jpg 540w,\n/static/853d434b15fecc13a6b2bbb64bfee1b4/47311/accessibility.jpg 1080w,\n/static/853d434b15fecc13a6b2bbb64bfee1b4/0047d/accessibility.jpg 1620w,\n/static/853d434b15fecc13a6b2bbb64bfee1b4/274e1/accessibility.jpg 2160w,\n/static/853d434b15fecc13a6b2bbb64bfee1b4/06565/accessibility.jpg 2694w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>On the left-hand side, there is a node tree representing all the items in the accessibility tree for the current page. Each item has two properties listed:</p>\n<ul>\n<li><em>Role</em> — the role this item has on the page (e.g., pushbutton, or footer, text leaf). This can be either a default role provided by the browser, or a role given to it via a <code class=\"language-text\">WAI-ARIA</code> role attribute.</li>\n<li><em>Name</em> — the name this item has on the page. The name depends on the element; for example, the name of most text elements is simply their textContent, whereas form elements’ names are the contents of their associated <code class=\"language-text\">&lt;label></code>.</li>\n</ul>\n<p>The cool thing here is that you can print the whole tree to <code class=\"language-text\">JSON</code>. This will help you to parse this structure looking for any specific non compliant item. As an example, <a href=\"https://medium.com/myplanet-musings/making-the-web-more-accessible-using-machine-learning-8a32eaafdb3a\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">someone made an ML model</a> to validate accessibility and this JSON is ideal for data prep for those models.</p>\n<h3 id=\"eyedropper\" style=\"position:relative;\"><a href=\"#eyedropper\" aria-label=\"eyedropper permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Eyedropper</h3>\n<p>If you want to select any particular colour in the current page, this tool is your friend. The fact that it works like a magnifying glass is really helpful to choose a colour in small areas of the page.</p>\n<p><img src=\"/c0943020253fa0f6845550187b7c8eaf/eyedropper.gif\" alt=\"Eyedropper in Firefox developer tools\"></p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>Firefox has come a long way and the team are working furiously adding new features and improvements with every minor and major release. Plus, we should always test our applications with multiple browsers and make sure users will have the same experience in every major browser.</p>\n<p>Have fun exploring these tricks and happy debugging.</p>\n<h2 id=\"update\" style=\"position:relative;\"><a href=\"#update\" aria-label=\"update permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Update</h2>\n<p><a href=\"https://dev.to/cecilelebleu\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Cécile Lebleu</a> mentioned in comments that I’ve forgot about CSS Grid inspector and it’s true. So let me tell you about it.</p>\n<h3 id=\"grid-inspector\" style=\"position:relative;\"><a href=\"#grid-inspector\" aria-label=\"grid inspector permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Grid inspector</h3>\n<p><a href=\"https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Examine_grid_layouts\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Grid inspector</a> is one of the unique tools in Firefox developer tools which allows you to examine <a href=\"https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">CSS Grid Layouts</a>, discovering grids present on a page, examining and modifying them inline, debugging layout issues, and more.</p>\n<p>In the HTML Pane, elements laid out using a grid have a “grid” marker beside them:</p>\n<p><img src=\"/6bb4d1cccde2b27fe797566c55f88348/girdmarker.jpg\" alt=\"Grid marker beside CSS grid element in Firefox developer tools\"></p>\n<p>In addition to that, in the CSS pane’s Rules view, any instance of a <code class=\"language-text\">display: grid</code> declaration gets a grid icon included within it: <span class=\"gatsby-resp-image-wrapper\" style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 24px; \">\n      <a class=\"gatsby-resp-image-link\" href=\"/static/c248ab782f6d8404d4d776ba9118c074/8f029/gridicon.png\" style=\"display: block\" target=\"_blank\" rel=\"noopener\">\n    <span class=\"gatsby-resp-image-background-image\" style=\"padding-bottom: 100%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAABYlAAAWJQFJUiTwAAACZklEQVR42q2UTWtTURCG838EEURBxVoRwUW7Ehd+LPwF0or+AVfuXLgSxfpRxdpKoyC2tQtBrJaCttc2SW8aSUiM9iNtEtvU3OSe1/POvSc9+QIXPTAw951nJvfOTE4E+3wirYLS5tVVk1bzlZh9yKj/Kbhvb2h+bW3Hw925X/oNfKhQnEwVxYRTkBgZsnZuc8FQ/fZ7GyefLGI9hHmuv0+LmcMYGbJ2rhQ0rcmW/iK6vInbM3kce7yIe19XMRovYNzdxIVXrhh9aoyRIcsc5vKwVsQ0+11qC+dexHH2eQwHHzji971MoH80gaND38XoU2OMDFn6zDXDaxoKX/1DpoRTw0tIFirY9Xxp0LXJH2L0qTFGhqxSXYZiPn325x/0ajhXru71cCotZg5jZMjauR2HMpMNCmaK1YY2oIsNhAWpMUaGbNtQ6mH5T9kyLkeT6B9ZxiHdn/NjLi6OJ0U7rgdAo0+NMTJkr0RXdG5QmLX0lIOCiY2K7NbN6QyO6AHc+pjFndm8aH0jCTH61BgjQ5Yac4NPV+2fPK9368yzWNMe3phOi9l7SGa+0x62FvySC4dS2hvKoO7foD2UUtBDsm0FzUNxtwZndQdDzjpO6H/B25UtzOW3saC1q29SYvSpMUaGLHOYawo3Fvu1W5DG9zxdwuGHDnr0G/QOx3Bam1ls+tQYE0azzGFu22LXfB+Fioex+AYO3F/A51xZ/lLs16WoK0afGmNkyDKHuV1vGy7tI2cN5Wq9AU3om2YivG14GCNjll91u77sjTfPtmae7QKtz20XLIEqb2OL8rToWZVVyPgdrux/BFGyG+WTrA4AAAAASUVORK5CYII='); background-size: cover; display: block;\"></span>\n  <img class=\"gatsby-resp-image-image\" alt=\"Grid icon\" title=\"\" src=\"/static/c248ab782f6d8404d4d776ba9118c074/8f029/gridicon.png\" srcset=\"/static/c248ab782f6d8404d4d776ba9118c074/8f029/gridicon.png 24w\" sizes=\"(max-width: 24px) 100vw, 24px\" style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\" loading=\"lazy\" decoding=\"async\">\n  </a>\n    </span>:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 420px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/450cd02e3f2705bbd5651062f8c974ee/65f94/gridicon.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 105.18518518518518%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAVABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAIBAwX/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/aAAwDAQACEAMQAAAB8qOmEMFioEf/xAAYEAACAwAAAAAAAAAAAAAAAAAQEQABIP/aAAgBAQABBQLFhOIf/8QAFREBAQAAAAAAAAAAAAAAAAAAEAH/2gAIAQMBAT8BIf/EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8BH//EABQQAQAAAAAAAAAAAAAAAAAAADD/2gAIAQEABj8CH//EAB4QAAIBAwUAAAAAAAAAAAAAAAABERAhMUFhcZHw/9oACAEBAAE/IWuez2SROdLEKKwYE7H/2gAMAwEAAgADAAAAEAwAPP/EABgRAAIDAAAAAAAAAAAAAAAAAAEQESFR/9oACAEDAQE/EANVpX//xAAVEQEBAAAAAAAAAAAAAAAAAAAQEf/aAAgBAgEBPxCEP//EAB8QAAIBAgcAAAAAAAAAAAAAAAERACFBEDFRgZGx0f/aAAgBAQABPxAiFSggC3ibuYYKmLnBB2PeCBNPOLUS2HE0T//Z'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Grid icon next in css pane\"\n        title=\"\"\n        src=\"/static/450cd02e3f2705bbd5651062f8c974ee/65f94/gridicon.jpg\"\n        srcset=\"/static/450cd02e3f2705bbd5651062f8c974ee/6f81f/gridicon.jpg 270w,\n/static/450cd02e3f2705bbd5651062f8c974ee/65f94/gridicon.jpg 420w\"\n        sizes=\"(max-width: 420px) 100vw, 420px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>You can click on the icon and the layout will be toggled in the page for you to see the grid with lines separating each cell:</p>\n<p><img src=\"/550baee639c0fb6c3f4c624642b9f338/gridview.gif\" alt=\"Toggle grid view\"></p>\n<p>By default line numbers and area names are hidden. But you can check the two checkbox on the right to enable these.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/01931c8aedc64c5f12f304eb90804274/38084/gridlinenumber.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 48.888888888888886%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAKABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAABQAE/8QAFQEBAQAAAAAAAAAAAAAAAAAAAQL/2gAMAwEAAhADEAAAAVinAJcVmqP/xAAcEAABAwUAAAAAAAAAAAAAAAAAAQIRBAUSEzL/2gAIAQEAAQUCiSrdg7a8UuHZ/8QAFREBAQAAAAAAAAAAAAAAAAAAARD/2gAIAQMBAT8BZ//EABURAQEAAAAAAAAAAAAAAAAAAAEQ/9oACAECAQE/ASf/xAAcEAABAwUAAAAAAAAAAAAAAAAAAhAhEjJBUXH/2gAIAQEABj8CwJpiNFzI43//xAAcEAEAAgIDAQAAAAAAAAAAAAABABExUSGhsfD/2gAIAQEAAT8hRmOthGPQvKhufQICsTufY5n/2gAMAwEAAgADAAAAEEwv/8QAFhEBAQEAAAAAAAAAAAAAAAAAARAR/9oACAEDAQE/EEZP/8QAFhEBAQEAAAAAAAAAAAAAAAAAERAx/9oACAECAQE/EG7P/8QAHBABAAICAwEAAAAAAAAAAAAAAQARITFxgZHw/9oACAEBAAE/EDBE1FeWRYG6CW9Ig5+XEEKHkwqg2T//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Line numbers and area names in grid view\"\n        title=\"\"\n        src=\"/static/01931c8aedc64c5f12f304eb90804274/47311/gridlinenumber.jpg\"\n        srcset=\"/static/01931c8aedc64c5f12f304eb90804274/6f81f/gridlinenumber.jpg 270w,\n/static/01931c8aedc64c5f12f304eb90804274/09d21/gridlinenumber.jpg 540w,\n/static/01931c8aedc64c5f12f304eb90804274/47311/gridlinenumber.jpg 1080w,\n/static/01931c8aedc64c5f12f304eb90804274/0047d/gridlinenumber.jpg 1620w,\n/static/01931c8aedc64c5f12f304eb90804274/274e1/gridlinenumber.jpg 2160w,\n/static/01931c8aedc64c5f12f304eb90804274/38084/gridlinenumber.jpg 2641w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>","timeToRead":6,"frontmatter":{"title":"Firefox Developer Tools can do that?","unformattedDate":"2019-08-08T00:00:00.000Z","date":"Aug 08, 2019","path":"/firefox-dev-tools/","author":"Yaser Adel Mehraban","tags":["webdev","firefox","devtools","showdev"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsTAAALEwEAmpwYAAACGklEQVR42jWK30tTYRzGz9Wh5aZuR2XDNKW5Hzj3W5e6GstVOi2lrIsIrUG5FD3bOnNuOzq6MaIgEF7BcFuSSkSYdRF01U1GUZddRNR/0Iu3wd729Jb0hQ8Pz/P9CKoct87NxVbfvntPfv0GAUB2dl+SmZk4keVZks9mSCYzTzLZLFHmM0RRFJJKJEgqlfqHklK4J5ME3zirQqGwHC2VN1EqbWPnxWsUi9t4vPEUhJSwsrKOtfUnKJa3kFMXoRbuYHFpCWpeRT6XR57nQjaHZHqhmkymqun0PASHuyM6ePEufBO7lRPRR6xz+jMLTxVZrrDHZh5+YbHSVxa6NM3Mli5mtjpY81ELMx4xsyZjK6upqWW1ujqm0dRU6vWGik5XByHgtkdPXb0HT+YNwte24F7+hkh6A+qDT5gtf8fN5z9wdkJGd/AcRoZjiAzG4D05CktXL6RGE0wco6m56nD5q21tbRDC4UD0wuR9dN96hjOX19CT+4je6ysYvfIKQWUPzuUPOD4+hW5/P/r9YfT5Q/B4AzAf64C+Xo9DGg28Xl9VlpNVl8sNIRgMRU6fv7HvGY7T3kiMusduU//QJO0bmKbeEZk6xxO0Z2CMOp0+and4qL1niFo7fbS9vYMaDA1UrzfQxsamny0trVSSGvYFfodFQbBKomgTOVpBsGl5Cn+TI3FEUXvwkySb1hKyiVqJ9/+7lrsHPnesfwDJmfEFmaj8igAAAABJRU5ErkJggg=="},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/ea9929276e8dd946cdec82b81551a1af/fa238/firefoxdevtools.png","srcSet":"/static/ea9929276e8dd946cdec82b81551a1af/067ac/firefoxdevtools.png 750w,\n/static/ea9929276e8dd946cdec82b81551a1af/47495/firefoxdevtools.png 1080w,\n/static/ea9929276e8dd946cdec82b81551a1af/43d27/firefoxdevtools.png 1366w,\n/static/ea9929276e8dd946cdec82b81551a1af/2d118/firefoxdevtools.png 1920w,\n/static/ea9929276e8dd946cdec82b81551a1af/fa238/firefoxdevtools.png 2400w","sizes":"(min-width: 2400px) 2400px, 100vw"},"sources":[{"srcSet":"/static/ea9929276e8dd946cdec82b81551a1af/ad590/firefoxdevtools.webp 750w,\n/static/ea9929276e8dd946cdec82b81551a1af/4ae4c/firefoxdevtools.webp 1080w,\n/static/ea9929276e8dd946cdec82b81551a1af/8367a/firefoxdevtools.webp 1366w,\n/static/ea9929276e8dd946cdec82b81551a1af/733b4/firefoxdevtools.webp 1920w,\n/static/ea9929276e8dd946cdec82b81551a1af/43628/firefoxdevtools.webp 2400w","type":"image/webp","sizes":"(min-width: 2400px) 2400px, 100vw"}]},"width":2400,"height":800}}}}}},{"node":{"id":"53d36f7f-5415-5d38-a5bf-b9dada4d2b23","html":"<p>First of all let me apologise for not writing as frequent as I would’ve liked. It’s been a crazy busy couple of weeks and I had heaps of fun speaking at <a href=\"https://dddperth.com/agenda?sessionId=00311b92-6c21-47a8-b8d2-af325581d6f9\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">DDD Perth 2019</a>.</p>\n<p>That taken care of, this time I thought let’s go through the new features which are added into the <a href=\"https://www.ecma-international.org/ecma-262/10.0/index.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">ECMAScript 2019 (aka ES2019 or ES10)</a>, because they’re super exciting and make our lives much easier 😎.</p>\n<!--more-->\n<h2 id=\"tldr\" style=\"position:relative;\"><a href=\"#tldr\" aria-label=\"tldr permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>TLDR;</h2>\n<p>At a glance, this version adds a few built-in functions on <code class=\"language-text\">Array.prototype</code>, <code class=\"language-text\">flat</code> and <code class=\"language-text\">flatMap</code>. Then we have <code class=\"language-text\">Object.fromEntries</code> for directly turning the return value of <code class=\"language-text\">Object.entries</code> into a new <em>Object</em>.</p>\n<p>We also have <code class=\"language-text\">trimStart</code> and <code class=\"language-text\">trimEnd</code> on <code class=\"language-text\">String.prototype</code> over the widely used non-standard versions <code class=\"language-text\">String.prototype.trimLeft</code> and <code class=\"language-text\">trimRight</code>.</p>\n<p>Another exciting feature is optional <code class=\"language-text\">catch</code> binding parameters. In addition to those, there are some JSON improvements, addition of <code class=\"language-text\">Symbol.prototype.description</code> which allows you to specify a description for your symbol, <code class=\"language-text\">JSON.stringify</code> returns well-formed <strong>UTF-8</strong> regardless of input, and at last clarifying <code class=\"language-text\">Function.prototype.toString</code> by requiring that it either return the corresponding original source text or a standard placeholder.</p>\n<p>So if you’re ready let’s dig in.</p>\n<h3 id=\"code-classlanguage-textarrayprototypeflat-flatmapcode\" style=\"position:relative;\"><a href=\"#code-classlanguage-textarrayprototypeflat-flatmapcode\" aria-label=\"code classlanguage textarrayprototypeflat flatmapcode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">Array.prototype.{flat, flatMap}</code></h3>\n<p><code class=\"language-text\">flat()</code> is a new method which let’s you create a one-dimensional array from a multi-dimensional one.</p>\n<p>Imagine we have an array like below:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"49924830256343690000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const myArray = [1, 2, 3, [4, 5, 6, [7, 8, 9, [10, 11, 12]]]];`, `49924830256343690000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">const</span> myArray <span class=\"token operator\">=</span> <span class=\"token punctuation\">[</span><span class=\"token number\">1</span><span class=\"token punctuation\">,</span> <span class=\"token number\">2</span><span class=\"token punctuation\">,</span> <span class=\"token number\">3</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">[</span><span class=\"token number\">4</span><span class=\"token punctuation\">,</span> <span class=\"token number\">5</span><span class=\"token punctuation\">,</span> <span class=\"token number\">6</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">[</span><span class=\"token number\">7</span><span class=\"token punctuation\">,</span> <span class=\"token number\">8</span><span class=\"token punctuation\">,</span> <span class=\"token number\">9</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">[</span><span class=\"token number\">10</span><span class=\"token punctuation\">,</span> <span class=\"token number\">11</span><span class=\"token punctuation\">,</span> <span class=\"token number\">12</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Prior to <code class=\"language-text\">flat</code> if you wanted to achieve this, you had to do something like this:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"72189429724704610000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const myNewArray = [].concat.apply([], myArray)\r\n// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]`, `72189429724704610000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">const</span> myNewArray <span class=\"token operator\">=</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span><span class=\"token function\">concat</span><span class=\"token punctuation\">.</span><span class=\"token function\">apply</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span> myArray<span class=\"token punctuation\">)</span>\r\n<span class=\"token comment\">// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>Or:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"44662782053453620000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`var myNewArray = myArray.reduce(\r\n  function(prev,curr) {\r\n    return prev.concat(curr)\r\n  }\r\n)\r\n// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]`, `44662782053453620000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">var</span> myNewArray <span class=\"token operator\">=</span> myArray<span class=\"token punctuation\">.</span><span class=\"token function\">reduce</span><span class=\"token punctuation\">(</span>\r\n  <span class=\"token keyword\">function</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">prev<span class=\"token punctuation\">,</span>curr</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">return</span> prev<span class=\"token punctuation\">.</span><span class=\"token function\">concat</span><span class=\"token punctuation\">(</span>curr<span class=\"token punctuation\">)</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">)</span>\r\n<span class=\"token comment\">// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>With this new addition, it would be as simple as:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"84530199458447840000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`var myNewArray = myArray.flat(4);\r\n// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]`, `84530199458447840000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">var</span> myNewArray <span class=\"token operator\">=</span> myArray<span class=\"token punctuation\">.</span><span class=\"token function\">flat</span><span class=\"token punctuation\">(</span><span class=\"token number\">4</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>You can also chain multiple calls:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"80981748057071930000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`var myNewArray = myArray.flat().flat().flat().flat();\r\n// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]`, `80981748057071930000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">var</span> myNewArray <span class=\"token operator\">=</span> myArray<span class=\"token punctuation\">.</span><span class=\"token function\">flat</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">flat</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">flat</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">flat</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>The argument into the <code class=\"language-text\">flat</code> function just specifies how deep it should look into the array. If you’re not sure how deep the array is, simply use <code class=\"language-text\">Infinity</code> as input:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"25517718046971470000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`var myNewArray = myArray.flat(Infinity);\r\n// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]`, `25517718046971470000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">var</span> myNewArray <span class=\"token operator\">=</span> myArray<span class=\"token punctuation\">.</span><span class=\"token function\">flat</span><span class=\"token punctuation\">(</span><span class=\"token number\">Infinity</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">// [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>And if you don’t provide any input, by default it only goes one level deep:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"77848700121435770000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`var myNewArray = myArray.flat(); \r\n// [1, 2, 3, 4, 5, 6, Array(4)];`, `77848700121435770000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">var</span> myNewArray <span class=\"token operator\">=</span> myArray<span class=\"token punctuation\">.</span><span class=\"token function\">flat</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> \r\n<span class=\"token comment\">// [1, 2, 3, 4, 5, 6, Array(4)];</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<hr/>\n<p><code class=\"language-text\">flatMap</code> on the other hand, allows you to map each element using a mapping function and then flattens the result into a new array. Think of it as chaining a <code class=\"language-text\">map</code> function with a single <code class=\"language-text\">flat</code>. However, it can be really helpful both in terms of usage and efficiency of execution.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"65071763123804690000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`let myArray = [1, 2, 3, 4, 5];\r\n\r\nlet mappedArray = myArray.map(x => [x, x * 2]);\r\n// [Array(2), Array(2), Array(2), Array(2), Array(2)]\r\n// 0: (2)[1, 2]\r\n// 1: (2)[2, 4]\r\n// 2: (2)[3, 6]\r\n// 3: (2)[4, 8]\r\n// 4: (2)[5, 10]\r\n\r\nlet mappedFlattenedArr = mappedArray.flat();\r\n\r\n// [1, 2, 2, 4, 3, 6, 4, 8, 5, 10]\r\n\r\nlet myNewArray = myArray.flatMap(v => [v, v * 2]);\r\n// [1, 2, 2, 4, 3, 6, 4, 8, 5, 10]`, `65071763123804690000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">let</span> myArray <span class=\"token operator\">=</span> <span class=\"token punctuation\">[</span><span class=\"token number\">1</span><span class=\"token punctuation\">,</span> <span class=\"token number\">2</span><span class=\"token punctuation\">,</span> <span class=\"token number\">3</span><span class=\"token punctuation\">,</span> <span class=\"token number\">4</span><span class=\"token punctuation\">,</span> <span class=\"token number\">5</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">let</span> mappedArray <span class=\"token operator\">=</span> myArray<span class=\"token punctuation\">.</span><span class=\"token function\">map</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">x</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">[</span>x<span class=\"token punctuation\">,</span> x <span class=\"token operator\">*</span> <span class=\"token number\">2</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">// [Array(2), Array(2), Array(2), Array(2), Array(2)]</span>\r\n<span class=\"token comment\">// 0: (2)[1, 2]</span>\r\n<span class=\"token comment\">// 1: (2)[2, 4]</span>\r\n<span class=\"token comment\">// 2: (2)[3, 6]</span>\r\n<span class=\"token comment\">// 3: (2)[4, 8]</span>\r\n<span class=\"token comment\">// 4: (2)[5, 10]</span>\r\n\r\n<span class=\"token keyword\">let</span> mappedFlattenedArr <span class=\"token operator\">=</span> mappedArray<span class=\"token punctuation\">.</span><span class=\"token function\">flat</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token comment\">// [1, 2, 2, 4, 3, 6, 4, 8, 5, 10]</span>\r\n\r\n<span class=\"token keyword\">let</span> myNewArray <span class=\"token operator\">=</span> myArray<span class=\"token punctuation\">.</span><span class=\"token function\">flatMap</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">v</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">[</span>v<span class=\"token punctuation\">,</span> v <span class=\"token operator\">*</span> <span class=\"token number\">2</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">// [1, 2, 2, 4, 3, 6, 4, 8, 5, 10]</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h3 id=\"code-classlanguage-textstringprototypetrimstart-trimendcode\" style=\"position:relative;\"><a href=\"#code-classlanguage-textstringprototypetrimstart-trimendcode\" aria-label=\"code classlanguage textstringprototypetrimstart trimendcode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">String.prototype.{trimStart, .trimEnd}</code></h3>\n<p>These methods are fairly obvious as to what they will do for us. Just keep in mind that we had <code class=\"language-text\">trimLeft</code> which will be replaced by <code class=\"language-text\">trimStart</code> and <code class=\"language-text\">trimRight</code> which will be replaced by <code class=\"language-text\">trimEnd</code>.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"38457501105619984000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`let message = ' This is a string with white space around ';\r\n\r\nmessage = message.trimStart();\r\n// 'This is a string with white space around '\r\n\r\nmessage = message.trimEnd();\r\n// 'This is a string with white space around'`, `38457501105619984000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">let</span> message <span class=\"token operator\">=</span> <span class=\"token string\">' This is a string with white space around '</span><span class=\"token punctuation\">;</span>\r\n\r\nmessage <span class=\"token operator\">=</span> message<span class=\"token punctuation\">.</span><span class=\"token function\">trimStart</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">// 'This is a string with white space around '</span>\r\n\r\nmessage <span class=\"token operator\">=</span> message<span class=\"token punctuation\">.</span><span class=\"token function\">trimEnd</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">// 'This is a string with white space around'</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h3 id=\"code-classlanguage-textobjectfromentriescode\" style=\"position:relative;\"><a href=\"#code-classlanguage-textobjectfromentriescode\" aria-label=\"code classlanguage textobjectfromentriescode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">Object.fromEntries</code></h3>\n<p>This method get an <code class=\"language-text\">Iterable</code> and transforms key-value pairs to an object. But let’s see what is an <code class=\"language-text\">Iterable</code>:</p>\n<blockquote>\n<p>JavaScript supports a protocol by which objects such as arrays can be used by control structures such as <code class=\"language-text\">for</code>…<code class=\"language-text\">of</code> and the spread operator <code class=\"language-text\">...</code> to loop through data sequentially. This is referred to as the iterable and the data structures that support this functionality are called iterables. While JavaScript provides maps, arrays and sets with an iterable property from the get-go, plain objects do not have this by default.</p>\n</blockquote>\n<p>To see this in action:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"91178216670960270000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`let entries = new Map([[&quot;name&quot;, &quot;john&quot;], [&quot;age&quot;, 22]]);\r\n\r\nlet newObj = Object.fromEntries(entries);\r\n// { name: 'john', age: 22 }`, `91178216670960270000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">let</span> entries <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Map</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token string\">\"name\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"john\"</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">[</span><span class=\"token string\">\"age\"</span><span class=\"token punctuation\">,</span> <span class=\"token number\">22</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">let</span> newObj <span class=\"token operator\">=</span> Object<span class=\"token punctuation\">.</span><span class=\"token function\">fromEntries</span><span class=\"token punctuation\">(</span>entries<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">// { name: 'john', age: 22 }</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>A real life use case is when parsing query strings:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"99278372025283800000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`let query = Object.fromEntries(new URLSearchParams('foo=bar&baz=qux'));\r\n\r\n// { foo: 'bar', baz: 'qux' }`, `99278372025283800000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">let</span> query <span class=\"token operator\">=</span> Object<span class=\"token punctuation\">.</span><span class=\"token function\">fromEntries</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">new</span> <span class=\"token class-name\">URLSearchParams</span><span class=\"token punctuation\">(</span><span class=\"token string\">'foo=bar&amp;baz=qux'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token comment\">// { foo: 'bar', baz: 'qux' }</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<h3 id=\"optional-catch-binding\" style=\"position:relative;\"><a href=\"#optional-catch-binding\" aria-label=\"optional catch binding permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Optional Catch Binding</h3>\n<p>Optional catch binding allows us to use <code class=\"language-text\">try/catch</code> without the <code class=\"language-text\">error</code> parameter inside the catch block.</p>\n<p>Previously you had to use this syntax regardless of whether you cared about <code class=\"language-text\">err</code> or not, such as when you had to fall back to feature to support older browsers:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"7040238626441298000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`try {\r\n  // try to use a web feature which may not be implemented\r\n} catch (unused) {\r\n  // fall back to a less desirable web feature with broader support\r\n}`, `7040238626441298000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">try</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token comment\">// try to use a web feature which may not be implemented</span>\r\n<span class=\"token punctuation\">}</span> <span class=\"token keyword\">catch</span> <span class=\"token punctuation\">(</span>unused<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token comment\">// fall back to a less desirable web feature with broader support</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>With <code class=\"language-text\">ES2019</code> you can do:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"38496643988703674000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`try {\r\n  // ...\r\n} catch {\r\n  // ...\r\n}`, `38496643988703674000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">try</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token comment\">// ...</span>\r\n<span class=\"token punctuation\">}</span> <span class=\"token keyword\">catch</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token comment\">// ...</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h3 id=\"code-classlanguage-textsymboldescriptioncode\" style=\"position:relative;\"><a href=\"#code-classlanguage-textsymboldescriptioncode\" aria-label=\"code classlanguage textsymboldescriptioncode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">Symbol.description</code></h3>\n<p>This new read-only description property is a string returning the optional description of <code class=\"language-text\">Symbol</code> objects. This method is encouraged to be used instead of <code class=\"language-text\">Symbol.prototype.toString</code>\r\nwhere it wasn’t obvious what will be returned.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"26366188561892413000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`let description = 'This symbol represents an emoji 😁';\r\n\r\nlet mySym = Symbol(description);\r\n// Symbol('This symbol represents an emoji 😁')\r\n\r\nconsole.log(mySym.description);\r\n'This symbol represents an emoji 😁'`, `26366188561892413000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">let</span> description <span class=\"token operator\">=</span> <span class=\"token string\">'This symbol represents an emoji 😁'</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">let</span> mySym <span class=\"token operator\">=</span> <span class=\"token function\">Symbol</span><span class=\"token punctuation\">(</span>description<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">// Symbol('This symbol represents an emoji 😁')</span>\r\n\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>mySym<span class=\"token punctuation\">.</span>description<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token string\">'This symbol represents an emoji 😁'</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h3 id=\"code-classlanguage-textfunctiontostringcode\" style=\"position:relative;\"><a href=\"#code-classlanguage-textfunctiontostringcode\" aria-label=\"code classlanguage textfunctiontostringcode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">Function.toString</code></h3>\n<p>This method is a really useful one which returns the source code of a function. Imagine doing a troubleshooting on a block of code which is using a third party function. This can potentially help you to see the implementation (given it’s got source maps).</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"40436426105960590000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`function myFn(emoji) {\r\n  let msg = \\`\\${emoji} is hellav an emoji\\`;\r\n  console.log(msg);\r\n}\r\n\r\nconsole.log(myFn.toString());\r\n\r\n// &quot;function myFn(emoji) {\r\n//   let msg = \\`\\${emoji} is hellav an emoji\\`;\r\n//   console.log(msg);\r\n// }&quot;`, `40436426105960590000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">function</span> <span class=\"token function\">myFn</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">emoji</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">let</span> msg <span class=\"token operator\">=</span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>emoji<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token string\"> is hellav an emoji</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">;</span>\r\n  console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>msg<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span>\r\n\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>myFn<span class=\"token punctuation\">.</span><span class=\"token function\">toString</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token comment\">// \"function myFn(emoji) {</span>\r\n<span class=\"token comment\">//   let msg = `${emoji} is hellav an emoji`;</span>\r\n<span class=\"token comment\">//   console.log(msg);</span>\r\n<span class=\"token comment\">// }\"</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Of course this doesn’t work for everything. If we try it for <code class=\"language-text\">map</code> function on array:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"23602153014650696000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`Array.prototype.map.toString();\r\n\r\n// &quot;function map() { [native code] }&quot;`, `23602153014650696000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token class-name\">Array</span><span class=\"token punctuation\">.</span>prototype<span class=\"token punctuation\">.</span>map<span class=\"token punctuation\">.</span><span class=\"token function\">toString</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token comment\">// \"function map() { [native code] }\"</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p>Since the implementation is not written in JavaScript, it will just show you that this function is written in native code.</p>\n<h3 id=\"code-classlanguage-textjsonstringifycode\" style=\"position:relative;\"><a href=\"#code-classlanguage-textjsonstringifycode\" aria-label=\"code classlanguage textjsonstringifycode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">JSON.stringify</code></h3>\n<p>The team have done an improvement with <strong>Unicode</strong> characters and now this method can’t return malformed data.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"4135517099700702700\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`// Non-BMP characters still serialize to surrogate pairs.\r\nJSON.stringify('𝌆')\r\n// → '&quot;𝌆&quot;'\r\nJSON.stringify('\\uD834\\uDF06')\r\n// → '&quot;𝌆&quot;'\r\n\r\n// Unpaired surrogate code units will serialize to escape sequences.\r\nJSON.stringify('\\uDF06\\uD834')\r\n// → '&quot;\\\\udf06\\\\ud834&quot;'\r\nJSON.stringify('\\uDEAD')\r\n// → '&quot;\\\\udead&quot;'`, `4135517099700702700`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">// Non-BMP characters still serialize to surrogate pairs.</span>\r\n<span class=\"token constant\">JSON</span><span class=\"token punctuation\">.</span><span class=\"token function\">stringify</span><span class=\"token punctuation\">(</span><span class=\"token string\">'𝌆'</span><span class=\"token punctuation\">)</span>\r\n<span class=\"token comment\">// → '\"𝌆\"'</span>\r\n<span class=\"token constant\">JSON</span><span class=\"token punctuation\">.</span><span class=\"token function\">stringify</span><span class=\"token punctuation\">(</span><span class=\"token string\">'\\uD834\\uDF06'</span><span class=\"token punctuation\">)</span>\r\n<span class=\"token comment\">// → '\"𝌆\"'</span>\r\n\r\n<span class=\"token comment\">// Unpaired surrogate code units will serialize to escape sequences.</span>\r\n<span class=\"token constant\">JSON</span><span class=\"token punctuation\">.</span><span class=\"token function\">stringify</span><span class=\"token punctuation\">(</span><span class=\"token string\">'\\uDF06\\uD834'</span><span class=\"token punctuation\">)</span>\r\n<span class=\"token comment\">// → '\"\\\\udf06\\\\ud834\"'</span>\r\n<span class=\"token constant\">JSON</span><span class=\"token punctuation\">.</span><span class=\"token function\">stringify</span><span class=\"token punctuation\">(</span><span class=\"token string\">'\\uDEAD'</span><span class=\"token punctuation\">)</span>\r\n<span class=\"token comment\">// → '\"\\\\udead\"'</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h3 id=\"code-classlanguage-textarraysortcode-stability\" style=\"position:relative;\"><a href=\"#code-classlanguage-textarraysortcode-stability\" aria-label=\"code classlanguage textarraysortcode stability permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">Array.sort</code> Stability</h3>\n<p>The team has decided to change the sort implementation so that it would be stable (that is, elements that compare equal must remain in their original order).</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"57057042649345120000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const grades = [\r\n  { topic: 'math', grade: 10 },\r\n  { topic: 'literacy', grade: 10 },\r\n  { topic: 'chemical', grade: 13 },\r\n  { topic: 'geography', grade: 12 },\r\n  { topic: 'modern history', grade: 12 },\r\n  { topic: 'art', grade: 13 },\r\n  { topic: 'computer basics', grade: 14 },\r\n  { topic: 'algebra', grade: 14 },\r\n];\r\n\r\ngrades.sort(a, b => a.grade - b.grade);\r\n\r\n// 0: {topic: &quot;math&quot;, grade: 10}\r\n// 1: {topic: &quot;literacy&quot;, grade: 10}\r\n// 2: {topic: &quot;geography&quot;, grade: 12}\r\n// 3: {topic: &quot;modern history&quot;, grade: 12}\r\n// 4: {topic: &quot;chemical&quot;, grade: 13}\r\n// 5: {topic: &quot;art&quot;, grade: 13}\r\n// 6: {topic: &quot;computer basics&quot;, grade: 14}\r\n// 7: {topic: &quot;algebra&quot;, grade: 14}`, `57057042649345120000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">const</span> grades <span class=\"token operator\">=</span> <span class=\"token punctuation\">[</span>\r\n  <span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">topic</span><span class=\"token operator\">:</span> <span class=\"token string\">'math'</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">grade</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">topic</span><span class=\"token operator\">:</span> <span class=\"token string\">'literacy'</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">grade</span><span class=\"token operator\">:</span> <span class=\"token number\">10</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">topic</span><span class=\"token operator\">:</span> <span class=\"token string\">'chemical'</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">grade</span><span class=\"token operator\">:</span> <span class=\"token number\">13</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">topic</span><span class=\"token operator\">:</span> <span class=\"token string\">'geography'</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">grade</span><span class=\"token operator\">:</span> <span class=\"token number\">12</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">topic</span><span class=\"token operator\">:</span> <span class=\"token string\">'modern history'</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">grade</span><span class=\"token operator\">:</span> <span class=\"token number\">12</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">topic</span><span class=\"token operator\">:</span> <span class=\"token string\">'art'</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">grade</span><span class=\"token operator\">:</span> <span class=\"token number\">13</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">topic</span><span class=\"token operator\">:</span> <span class=\"token string\">'computer basics'</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">grade</span><span class=\"token operator\">:</span> <span class=\"token number\">14</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">topic</span><span class=\"token operator\">:</span> <span class=\"token string\">'algebra'</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">grade</span><span class=\"token operator\">:</span> <span class=\"token number\">14</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n<span class=\"token punctuation\">]</span><span class=\"token punctuation\">;</span>\r\n\r\ngrades<span class=\"token punctuation\">.</span><span class=\"token function\">sort</span><span class=\"token punctuation\">(</span>a<span class=\"token punctuation\">,</span> <span class=\"token parameter\">b</span> <span class=\"token operator\">=></span> a<span class=\"token punctuation\">.</span>grade <span class=\"token operator\">-</span> b<span class=\"token punctuation\">.</span>grade<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token comment\">// 0: {topic: \"math\", grade: 10}</span>\r\n<span class=\"token comment\">// 1: {topic: \"literacy\", grade: 10}</span>\r\n<span class=\"token comment\">// 2: {topic: \"geography\", grade: 12}</span>\r\n<span class=\"token comment\">// 3: {topic: \"modern history\", grade: 12}</span>\r\n<span class=\"token comment\">// 4: {topic: \"chemical\", grade: 13}</span>\r\n<span class=\"token comment\">// 5: {topic: \"art\", grade: 13}</span>\r\n<span class=\"token comment\">// 6: {topic: \"computer basics\", grade: 14}</span>\r\n<span class=\"token comment\">// 7: {topic: \"algebra\", grade: 14}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h3 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h3>\n<p>In general JavaScript is moving in the right direction for helping developers write more stable, reliable and consistent code. You can find more information on their <a href=\"https://github.com/tc39/proposals\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GitHub repo here</a>.</p>\n<p>Hope to see more awesome features in JavaScript and see you soon with another article.</p>","timeToRead":5,"frontmatter":{"title":"JavaScript: useful features of ECMAScript 2019 reviewed","unformattedDate":"2019-08-06T00:00:00.000Z","date":"Aug 06, 2019","path":"/es2019/","author":"Yaser Adel Mehraban","tags":["webdev","javascript","showdev","es2019"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB10lEQVR42k2R7U8TQRDGr+2+9CpSaG0JatTg3+4HP5oSqR8gEEBKCUqtBQlEMSZo6Nu99a7X291xZtsak83lsvv8npl5xtEPJei7MHDN0NXDoh5JPRZ4lP3Br1rcSHxCDSpJ3C8h6CwxV42IMZ6k4wtICiYQEHGYMDOW83trJ/5ZOECYVAtMGJ9DyE0oep/qqVe8/7F2960CCcN7e8iCyoyKBM+7stU4BNxEAmZ89FDafrcFkL//udrceQmQU5GEUICPLiRWY66GRWfZqiUnUscCpZ3zjePDZwCOSgvvG1uD3yug8vQUChMwatDWd/RiSEYPCdcJQ/j2en1//znCviebO68mGMGsYKY4P8JcY/92fmeZECd4yk3KQOcCT2w3Xn+/XW+fbu7tkUsWk6+ekExTcQvP29Z2WhWJNBIJhqxzw/6jOOahLyNMweTI1OQh5ToSJP4fzgIJinXbld0PmxdnT96+edE6qp0c17qd8lVv9eb68WW3fH5aaX+sZZHEFc53tkib4Bm/65UvWtWbr2snB/WD3Y3LTqV1VP/crv75tdI6rDUbT7+cVVPcVmi3hWnjujB05WEzEsPLfKlw/qQAU6YDYWIMCSdimScUhhLammMiYeD+BWwvoragF0BGAAAAAElFTkSuQmCC"},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/0010bff258a8fb3470b02787d5fbb94a/bda6f/es.jpg","srcSet":"/static/0010bff258a8fb3470b02787d5fbb94a/ebf29/es.jpg 750w,\n/static/0010bff258a8fb3470b02787d5fbb94a/1c35b/es.jpg 1080w,\n/static/0010bff258a8fb3470b02787d5fbb94a/bda6f/es.jpg 1280w","sizes":"(min-width: 1280px) 1280px, 100vw"},"sources":[{"srcSet":"/static/0010bff258a8fb3470b02787d5fbb94a/ad370/es.webp 750w,\n/static/0010bff258a8fb3470b02787d5fbb94a/10f26/es.webp 1080w,\n/static/0010bff258a8fb3470b02787d5fbb94a/5d501/es.webp 1280w","type":"image/webp","sizes":"(min-width: 1280px) 1280px, 100vw"}]},"width":1280,"height":710}}}}}},{"node":{"id":"d6a0252f-70c0-5d1a-861f-fe0802407d8b","html":"<p>I’ve been sitting many interview sessions recently as part of our recruitment process and let me tell you it’s one of the hardest tasks I’ve ever had. In this post I wanted to share my findings and approach with you so we can all be more intelligent, inclusive and successful in our hiring process. And I am super keen to hear from you in comments 👇🏼.</p>\n<!--more-->\n<h2 id=\"context\" style=\"position:relative;\"><a href=\"#context\" aria-label=\"context permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Context</h2>\n<p>The most important part of every interview is how to qualify a candidate without being too specific about a technology or framework. It’s about measuring their abilities and potentials rather than asking questions where any person can find somewhere and memorise the answer.</p>\n<p>We, at <a href=\"https://join.readify.net/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Readify</a>, have a very specific and complex (if I may say so, which I just did 😁) process for hiring great fits, not just technical, but also culturally.</p>\n<p>To be able to do this, we need to be very careful with what is being asked during our technical interviews which is reached after a coding challenge and live coding session.</p>\n<h2 id=\"what-do-we-ask\" style=\"position:relative;\"><a href=\"#what-do-we-ask\" aria-label=\"what do we ask permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What do we ask</h2>\n<p>I don’t want to review our hiring process, more focus on what is being asked and how do we phrase them. There are plenty of sites which show you what to ask and unfortunately most of them have some predictable questions like:</p>\n<blockquote>\n<p>Where do you see yourself in 5 years?</p>\n</blockquote>\n<p>To be honest I don’t even know what happens for me in 5 months, let alone 5 years. So the question is what should we ask to be able to find out as much as we can about a candidate without falling into trap of asking fruitless questions.</p>\n<p>To determine whether someone is a good fit for the job, you want to draw them out, ask a mix of technical and situational questions, and listen closely to not only what they have to say but how they say it. The so called technical questions shouldn’t be around what, but about how. You want to evaluate how they perform in certain situations like solving a tough problem.</p>\n<p>So let’s begin.</p>\n<h2 id=\"1-what-challenging-problem-have-you-had-in-the-last-couple-of-months\" style=\"position:relative;\"><a href=\"#1-what-challenging-problem-have-you-had-in-the-last-couple-of-months\" aria-label=\"1 what challenging problem have you had in the last couple of months permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. What challenging problem have you had in the last couple of months?</h2>\n<p>This question is like an ice breaker. It will put them at ease because they will be able to talk about something they’re comfortable with. This will also give you an opportunity to see how they go about solving a problem. You can go in more details in areas where you see value in, such as <em>why did you choose this specific way to solve it</em>, or <em>why didn’t you try blah</em>.</p>\n<p>You can get an overview of their team work too, did they collaborate on solving his problem, or did they help someone or get help from them.</p>\n<h2 id=\"2-what-resources-do-you-use-to-learn-or-sharpen-your-skills\" style=\"position:relative;\"><a href=\"#2-what-resources-do-you-use-to-learn-or-sharpen-your-skills\" aria-label=\"2 what resources do you use to learn or sharpen your skills permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. What resources do you use to learn or sharpen your skills?</h2>\n<p>Many developers turn to websites such as <a href=\"https://stackoverflow.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">StackOverflow</a>, <a href=\"https://medium.com\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Medium</a>, or <a href=\"https://dev.to\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Dev</a> when they need help with something. Serious professionals will have their own selection of websites, online communities, social media feeds and other resources specific to their interests. The answer to this question will give you an indication of how engaged the candidate is with the broader IT community.</p>\n<p>Apart from those, Meetups, conferences, YouTube Channels, taking online courses, joining hackathons, plugging away at personal IT projects and many more can be discussed to see how the candidate keep themselves up to date, or find answer to a problem.</p>\n<h2 id=\"3-how-do-you-explain-x-in-simple-terms\" style=\"position:relative;\"><a href=\"#3-how-do-you-explain-x-in-simple-terms\" aria-label=\"3 how do you explain x in simple terms permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3. How do you explain X in simple terms?</h2>\n<p>This is very good to see how they can simplify a technical term or subject. It’s very good to understand how deep they know something or how broad their knowledge is.</p>\n<p>Another aspect about this is to be able to communicate to stakeholders of a project. If you can explain a subject to your <em>Product Owner</em>, <em>BA</em>, <em>Tester</em> and so on, your whole team would be more successful delivering your project.</p>\n<h2 id=\"4-what-qualities-do-you-think-is-required-for-x\" style=\"position:relative;\"><a href=\"#4-what-qualities-do-you-think-is-required-for-x\" aria-label=\"4 what qualities do you think is required for x permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>4. What qualities do you think is required for X?</h2>\n<p>This questions will help you unravel some of the candidate’s expectations and also how they see the role. Some people may focus on certifications and technical abilities, while others may talk more about problem solving, attention to detail, communication and other general job skills. Look for candidates who give a nice balance of both.</p>\n<h2 id=\"5-what-are-x-words-your-colleagues-describe-you-with\" style=\"position:relative;\"><a href=\"#5-what-are-x-words-your-colleagues-describe-you-with\" aria-label=\"5 what are x words your colleagues describe you with permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>5. What are X words your colleagues describe you with?</h2>\n<p>This might sound cliché, but it will help you find out about some of their aspects not found in resume or social media profiles. It also gives insight into how the individual perceives themselves and the role they’re applying for. For example, if their answer focuses on their creative side but the position is very analytical in nature, the job may not be a good fit.</p>\n<h2 id=\"6-tell-us-about-a-challenging-situation-you-had-which-resulted-in-failure-such-as-missing-a-deadline-or-a-promotion-being-rejected\" style=\"position:relative;\"><a href=\"#6-tell-us-about-a-challenging-situation-you-had-which-resulted-in-failure-such-as-missing-a-deadline-or-a-promotion-being-rejected\" aria-label=\"6 tell us about a challenging situation you had which resulted in failure such as missing a deadline or a promotion being rejected permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>6. Tell us about a challenging situation you had which resulted in failure, such as missing a deadline or a promotion being rejected?</h2>\n<p>We all deals with professional setbacks at some point in our career. What you want to know is how people handled — and what they learned from — those situations. The best employees are resilient, using setbacks as a springboard toward positive changes. So listen to not only the problem they mention, but also what they did after the disappointment.</p>\n<h2 id=\"7-what-is-your-most-and-least-favourite-frameworkproduct\" style=\"position:relative;\"><a href=\"#7-what-is-your-most-and-least-favourite-frameworkproduct\" aria-label=\"7 what is your most and least favourite frameworkproduct permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>7. What is your most and least favourite framework/product?</h2>\n<p>This question helps you evaluate enthusiasm and knowledge. Do candidates become animated when discussing the advantages and disadvantages of certain tools/framework/library? Do they admire solid engineering, sleek design, intuitive user experience or another aspect of good technology?</p>\n<p>What is their focus area in a tool, what they look for and what value they see in their favourite choice. These will give you great insight about them.</p>\n<h2 id=\"8-what-are-the-pros-and-cons-of-working-in-an-agile-environment\" style=\"position:relative;\"><a href=\"#8-what-are-the-pros-and-cons-of-working-in-an-agile-environment\" aria-label=\"8 what are the pros and cons of working in an agile environment permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>8. What are the pros and cons of working in an agile environment?</h2>\n<p>This question can help you understand their perception of agile, how they operate in a fast pace environment which means lots of quick meetings and a steady stream of feedback from fellow team members. Most developers don’t like too many meetings especially if they’re doing SCRUM until they realise the benefit of each of those and how they help reduce the time waste.</p>\n<p>A candidate’s answer to this question can tell you not only their level of understanding of this popular environment, but also their attitudes toward collaboration and communication.</p>\n<h2 id=\"9-what-was-your-last-presentation\" style=\"position:relative;\"><a href=\"#9-what-was-your-last-presentation\" aria-label=\"9 what was your last presentation permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>9. What was your last presentation?</h2>\n<p>First of all, let me clear the fact that by presentation I don’t mean public speaking like conferences and meetups. However, having public speaking background is a bonus since it proves a couple of points.</p>\n<p>Today’s tech workers can’t be lone wolves. They have to discuss changes with colleagues, coordinate with other departments, advocate for platforms they prefer and much more. While not everyone has to love public speaking, your new hire should be able to conduct research, put together a solid presentation and persuade stakeholders why <code class=\"language-text\">X</code> is better than <code class=\"language-text\">Y</code>.</p>\n<h2 id=\"10-how-do-you-manage-your-work-life-balance\" style=\"position:relative;\"><a href=\"#10-how-do-you-manage-your-work-life-balance\" aria-label=\"10 how do you manage your work life balance permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>10. How do you manage your work life balance?</h2>\n<p>There many scenarios where one has to work harder than usual. A pressing deadline, on-call duties (fortunately we don’t have this), or simply someone who is addicted to spend all their time working are examples where we need to be careful about.</p>\n<p>While you want dedicated team members, you should also seek employees who know how to relax and take care of themselves. Burnout is a very real problem in our industry, and top performers have good strategies in place to prevent it. As a follow up to their answer, you could talk about how your company supports a healthy work life balance (we do this via multiple ways) — something that can be very tempting for candidates with multiple offers.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>There are many questions you can ask during an interview, but those who target intelligence, creativity, and learning abilities are the most helpful ones. When interviewing a candidate, always look for their strength and quick learning ability. Don’t ask technical questions which their answer wouldn’t help you uncover the candidate’s potential. People can spend a couple of days and find out those questions and their answers from many sources. But the questions mentioned here and those similar in nature would help you find a good fit for your team.</p>\n<p>And a final advice from truly yours, don’t be a jerk when interviewing a candidate. Don’t be biased on gender, background, appearance, and other factors which prevent you from finding good people.</p>","timeToRead":5,"frontmatter":{"title":"10 questions to ask in a technical interview","unformattedDate":"2019-07-17T00:00:00.000Z","date":"Jul 17, 2019","path":"/interview-questions/","author":"Yaser Adel Mehraban","tags":["recruitment","interview","questions"],"thumbnail":null}}},{"node":{"id":"a97edd92-c626-50e0-88f7-816e694d07af","html":"<p>You might be wondering why I am writing less these days. I assure you, it’s not because I am getting lazy (I am ATM 🤩), it’s just that I am on a long overdue holiday. But to keep my juices going, I thought now that I am having fun, let’s write a fun post 😊.</p>\n<!--more-->\n<p>In this post I will go through some of the funniest yet unbelievable JavaScript snippets ever. Are you ready?</p>\n<h2 id=\"code-classlanguage-textcode-is-equal-code-classlanguage-textcode\" style=\"position:relative;\"><a href=\"#code-classlanguage-textcode-is-equal-code-classlanguage-textcode\" aria-label=\"code classlanguage textcode is equal code classlanguage textcode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">[]</code> is equal <code class=\"language-text\">![]</code></h2>\n<p>Array is equal to not array 😂:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"26651508502417200000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`;[] == ![] // -> true`, `26651508502417200000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token punctuation\">;</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token operator\">!</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token comment\">// -> true</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p><strong>💡 What’s happening?</strong></p>\n<p>The abstract equality operator converts both sides to numbers before comparing them, and both sides will be converted to <code class=\"language-text\">0</code> for different reasons. Arrays are truthy, so the right hand side becomes false which then is coerced to <code class=\"language-text\">0</code>. On the left however, the empty array is coerced to a number without becoming a boolean first, and empty arrays are coerced to <code class=\"language-text\">0</code>, despite being truthy 🤯.</p>\n<h2 id=\"code-classlanguage-texttruecode-is-code-classlanguage-textfalsecode\" style=\"position:relative;\"><a href=\"#code-classlanguage-texttruecode-is-code-classlanguage-textfalsecode\" aria-label=\"code classlanguage texttruecode is code classlanguage textfalsecode permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">true</code> is <code class=\"language-text\">false</code></h2>\n<p>True is false:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"9034923397130745000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`!!'false' == !!'true' // -> true\r\n!!'false' === !!'true' // -> true`, `9034923397130745000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token operator\">!</span><span class=\"token operator\">!</span><span class=\"token string\">'false'</span> <span class=\"token operator\">==</span> <span class=\"token operator\">!</span><span class=\"token operator\">!</span><span class=\"token string\">'true'</span> <span class=\"token comment\">// -> true</span>\r\n<span class=\"token operator\">!</span><span class=\"token operator\">!</span><span class=\"token string\">'false'</span> <span class=\"token operator\">===</span> <span class=\"token operator\">!</span><span class=\"token operator\">!</span><span class=\"token string\">'true'</span> <span class=\"token comment\">// -> true</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p><strong>💡 What’s happening?</strong></p>\n<p><code class=\"language-text\">true</code> is <code class=\"language-text\">truthy</code> and is represented by value 1 (number), <code class=\"language-text\">true</code> in string form, is <code class=\"language-text\">NaN</code>. So:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"64732920689131280000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`true == 'true' // -> false\r\nfalse == 'false' // -> false`, `64732920689131280000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token boolean\">true</span> <span class=\"token operator\">==</span> <span class=\"token string\">'true'</span> <span class=\"token comment\">// -> false</span>\r\n<span class=\"token boolean\">false</span> <span class=\"token operator\">==</span> <span class=\"token string\">'false'</span> <span class=\"token comment\">// -> false</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p><code class=\"language-text\">false</code> is not the empty string, so it’s a truthy value, so:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"20956050965641216000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`!!'false' // -> true\r\n!!'true' // -> true`, `20956050965641216000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token operator\">!</span><span class=\"token operator\">!</span><span class=\"token string\">'false'</span> <span class=\"token comment\">// -> true</span>\r\n<span class=\"token operator\">!</span><span class=\"token operator\">!</span><span class=\"token string\">'true'</span> <span class=\"token comment\">// -> true</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>Cool, ha? 😎</p>\n<h2 id=\"banana-\" style=\"position:relative;\"><a href=\"#banana-\" aria-label=\"banana  permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>baNaNa 🍌</h2>\n<p>Let’s create a banana:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"21509140909671375000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`'b' + 'a' + +'a' + 'a' // -> baNaNa`, `21509140909671375000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token string\">'b'</span> <span class=\"token operator\">+</span> <span class=\"token string\">'a'</span> <span class=\"token operator\">+</span> <span class=\"token operator\">+</span><span class=\"token string\">'a'</span> <span class=\"token operator\">+</span> <span class=\"token string\">'a'</span> <span class=\"token comment\">// -> baNaNa</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p><strong>💡 What’s happening?</strong></p>\n<p>This one is an old trick, remixed. The expression is converted to <code class=\"language-text\">\"ba\" + (+\"a\") + \"a\"</code>, and since <code class=\"language-text\">\"a\"</code> is converted to a number, it becomes <code class=\"language-text\">NaN</code>.</p>\n<h2 id=\"lets-fail\" style=\"position:relative;\"><a href=\"#lets-fail\" aria-label=\"lets fail permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Let’s fail</h2>\n<p>You wouldn’t believe this in your wildest dreams, but:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"58343346041168730000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`;(![] + [])[+[]] +\r\n  (![] + [])[+!+[]] +\r\n  ([![]] + [][[]])[+!+[] + [+[]]] +\r\n  (![] + [])[!+[] + !+[]]\r\n// -> 'fail'`, `58343346041168730000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token punctuation\">;</span><span class=\"token punctuation\">(</span><span class=\"token operator\">!</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">+</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">[</span><span class=\"token operator\">+</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">+</span>\r\n  <span class=\"token punctuation\">(</span><span class=\"token operator\">!</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">+</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">[</span><span class=\"token operator\">+</span><span class=\"token operator\">!</span><span class=\"token operator\">+</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">+</span>\r\n  <span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span><span class=\"token operator\">!</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">+</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">[</span><span class=\"token operator\">+</span><span class=\"token operator\">!</span><span class=\"token operator\">+</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">+</span> <span class=\"token punctuation\">[</span><span class=\"token operator\">+</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">+</span>\r\n  <span class=\"token punctuation\">(</span><span class=\"token operator\">!</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">+</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">[</span><span class=\"token operator\">!</span><span class=\"token operator\">+</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">+</span> <span class=\"token operator\">!</span><span class=\"token operator\">+</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span>\r\n<span class=\"token comment\">// -> 'fail'</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p><strong>💡 What’s happening?</strong></p>\n<p>If we break this lot into smaller pieces, we notice that the following pattern occurs often:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"87340360780387840000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`![] + [] // -> 'false'\r\n![] // -> false`, `87340360780387840000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token operator\">!</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">+</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token comment\">// -> 'false'</span>\r\n<span class=\"token operator\">!</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token comment\">// -> false</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>We try adding <code class=\"language-text\">[]</code> to <code class=\"language-text\">false</code>, but because of a number of function calls internally, we’ll end up converting the right operand into a string:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"11072329738269215000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`![] + [].toString() // -> 'false'`, `11072329738269215000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token operator\">!</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">+</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span><span class=\"token function\">toString</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token comment\">// -> 'false'</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Thinking of a string as an array we can access its first character via <code class=\"language-text\">[0]</code>:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"91720821382743540000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`'false'[0] // -> 'f'`, `91720821382743540000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token string\">'false'</span><span class=\"token punctuation\">[</span><span class=\"token number\">0</span><span class=\"token punctuation\">]</span> <span class=\"token comment\">// -> 'f'</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>The rest is obvious, but the <code class=\"language-text\">i</code> is tricky. The <code class=\"language-text\">i</code> in fail is grabbed by generating the string <code class=\"language-text\">falseundefined</code> and taking the element on index <code class=\"language-text\">['10']</code>.</p>\n<h2 id=\"array-equality-is-evil-\" style=\"position:relative;\"><a href=\"#array-equality-is-evil-\" aria-label=\"array equality is evil  permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Array equality is evil 👾</h2>\n<p>Array equality is evil in JavaScript, see below:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"50579267364389134000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`[] == ''   // -> true\r\n[] == 0    // -> true\r\n[''] == '' // -> true\r\n[0] == 0   // -> true\r\n[0] == ''  // -> false\r\n[''] == 0  // -> true\r\n\r\n[null] == ''      // true\r\n[null] == 0       // true\r\n[undefined] == '' // true\r\n[undefined] == 0  // true\r\n\r\n[[]] == 0  // true\r\n[[]] == '' // true\r\n\r\n[[[[[[]]]]]] == '' // true\r\n[[[[[[]]]]]] == 0  // true\r\n\r\n[[[[[[ null ]]]]]] == 0  // true\r\n[[[[[[ null ]]]]]] == '' // true\r\n\r\n[[[[[[ undefined ]]]]]] == 0  // true\r\n[[[[[[ undefined ]]]]]] == '' // true`, `50579267364389134000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token string\">''</span>   <span class=\"token comment\">// -> true</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token number\">0</span>    <span class=\"token comment\">// -> true</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token string\">''</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token string\">''</span> <span class=\"token comment\">// -> true</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token number\">0</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token number\">0</span>   <span class=\"token comment\">// -> true</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token number\">0</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token string\">''</span>  <span class=\"token comment\">// -> false</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token string\">''</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token number\">0</span>  <span class=\"token comment\">// -> true</span>\r\n\r\n<span class=\"token punctuation\">[</span><span class=\"token keyword\">null</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token string\">''</span>      <span class=\"token comment\">// true</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token keyword\">null</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token number\">0</span>       <span class=\"token comment\">// true</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token keyword\">undefined</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token string\">''</span> <span class=\"token comment\">// true</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token keyword\">undefined</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token number\">0</span>  <span class=\"token comment\">// true</span>\r\n\r\n<span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token number\">0</span>  <span class=\"token comment\">// true</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token string\">''</span> <span class=\"token comment\">// true</span>\r\n\r\n<span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token string\">''</span> <span class=\"token comment\">// true</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token number\">0</span>  <span class=\"token comment\">// true</span>\r\n\r\n<span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span> <span class=\"token keyword\">null</span> <span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token number\">0</span>  <span class=\"token comment\">// true</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span> <span class=\"token keyword\">null</span> <span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token string\">''</span> <span class=\"token comment\">// true</span>\r\n\r\n<span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span> <span class=\"token keyword\">undefined</span> <span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token number\">0</span>  <span class=\"token comment\">// true</span>\r\n<span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">[</span> <span class=\"token keyword\">undefined</span> <span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">]</span> <span class=\"token operator\">==</span> <span class=\"token string\">''</span> <span class=\"token comment\">// true</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p><strong>💡 What’s happening?</strong></p>\n<p>The explanation behind this is rather long. So I introduce you to <a href=\"https://www.ecma-international.org/ecma-262/#sec-abstract-equality-comparison\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">section 7.2.13 Abstract Equality Comparison</a> of the specification.</p>\n<h2 id=\"code-classlanguage-textparseintcode-is-just-bad\" style=\"position:relative;\"><a href=\"#code-classlanguage-textparseintcode-is-just-bad\" aria-label=\"code classlanguage textparseintcode is just bad permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">parseInt</code> is just bad</h2>\n<p><code class=\"language-text\">parseInt</code> is famous by its quirks, I just mention one of the most famous ones:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"43524182068676450000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`parseInt('f**k') // -> NaN\r\nparseInt('f**k', 16) // -> 15`, `43524182068676450000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token function\">parseInt</span><span class=\"token punctuation\">(</span><span class=\"token string\">'f**k'</span><span class=\"token punctuation\">)</span> <span class=\"token comment\">// -> NaN</span>\r\n<span class=\"token function\">parseInt</span><span class=\"token punctuation\">(</span><span class=\"token string\">'f**k'</span><span class=\"token punctuation\">,</span> <span class=\"token number\">16</span><span class=\"token punctuation\">)</span> <span class=\"token comment\">// -> 15</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p><strong>💡 What’s happening?</strong></p>\n<p>This happens because <code class=\"language-text\">parseInt</code> will continue parsing character by character until it hits one it doesn’t know. The <code class=\"language-text\">f</code> in <code class=\"language-text\">f**k</code> is the hexadecimal digit <code class=\"language-text\">15</code>.</p>\n<h2 id=\"code-classlanguage-textnancode-is-not-a-number\" style=\"position:relative;\"><a href=\"#code-classlanguage-textnancode-is-not-a-number\" aria-label=\"code classlanguage textnancode is not a number permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><code class=\"language-text\">NaN</code> is <del>not</del> a number</h2>\n<p>Type of <code class=\"language-text\">NaN</code> is a <code class=\"language-text\">number</code>:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"91131925925570530000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`typeof NaN // -> 'number'`, `91131925925570530000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">typeof</span> <span class=\"token number\">NaN</span> <span class=\"token comment\">// -> 'number'</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p><strong>💡 What’s happening?</strong></p>\n<p>Explanations of how <code class=\"language-text\">typeof</code> and <code class=\"language-text\">instanceof</code> operators work:</p>\n<ul>\n<li><a href=\"https://www.ecma-international.org/ecma-262/#sec-typeof-operator\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">12.5.5 The <code class=\"language-text\">typeof</code> Operator</a></li>\n<li><a href=\"https://www.ecma-international.org/ecma-262/#sec-instanceofoperator\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">12.10.4 Runtime Semantics: <code class=\"language-text\">InstanceofOperator(O,C)</code></a></li>\n</ul>\n<h2 id=\"comparison-of-three-numbers\" style=\"position:relative;\"><a href=\"#comparison-of-three-numbers\" aria-label=\"comparison of three numbers permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Comparison of three numbers</h2>\n<p>This one is gold:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"39885567139412296000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`1 < 2 < 3 // -> true\r\n3 > 2 > 1 // -> false`, `39885567139412296000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token number\">1</span> <span class=\"token operator\">&lt;</span> <span class=\"token number\">2</span> <span class=\"token operator\">&lt;</span> <span class=\"token number\">3</span> <span class=\"token comment\">// -> true</span>\r\n<span class=\"token number\">3</span> <span class=\"token operator\">></span> <span class=\"token number\">2</span> <span class=\"token operator\">></span> <span class=\"token number\">1</span> <span class=\"token comment\">// -> false</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p><strong>💡 What’s happening?</strong></p>\n<p>Why does this work that way? Well, the problem is in the first part of an expression. Here’s how it works:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"86981729510308150000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`1 < 2 < 3 // 1 < 2 -> true\r\ntrue < 3 // true -> 1\r\n1 < 3 // -> true\r\n\r\n3 > 2 > 1 // 3 > 2 -> true\r\ntrue > 1 // true -> 1\r\n1 > 1 // -> false`, `86981729510308150000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token number\">1</span> <span class=\"token operator\">&lt;</span> <span class=\"token number\">2</span> <span class=\"token operator\">&lt;</span> <span class=\"token number\">3</span> <span class=\"token comment\">// 1 &lt; 2 -> true</span>\r\n<span class=\"token boolean\">true</span> <span class=\"token operator\">&lt;</span> <span class=\"token number\">3</span> <span class=\"token comment\">// true -> 1</span>\r\n<span class=\"token number\">1</span> <span class=\"token operator\">&lt;</span> <span class=\"token number\">3</span> <span class=\"token comment\">// -> true</span>\r\n\r\n<span class=\"token number\">3</span> <span class=\"token operator\">></span> <span class=\"token number\">2</span> <span class=\"token operator\">></span> <span class=\"token number\">1</span> <span class=\"token comment\">// 3 > 2 -> true</span>\r\n<span class=\"token boolean\">true</span> <span class=\"token operator\">></span> <span class=\"token number\">1</span> <span class=\"token comment\">// true -> 1</span>\r\n<span class=\"token number\">1</span> <span class=\"token operator\">></span> <span class=\"token number\">1</span> <span class=\"token comment\">// -> false</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>You can fix this with greater than or equal operator (<code class=\"language-text\">>=</code>):</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"37135254203092490000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`3 > 2 >= 1 // true`, `37135254203092490000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token number\">3</span> <span class=\"token operator\">></span> <span class=\"token number\">2</span> <span class=\"token operator\">>=</span> <span class=\"token number\">1</span> <span class=\"token comment\">// true</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Read more about Relational operators in the specification:</p>\n<ul>\n<li><a href=\"https://www.ecma-international.org/ecma-262/#sec-relational-operators\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">12.10 Relational Operators</a></li>\n</ul>\n<p>And that’s just some of the fun we can have with JavaScript. No wonder some people do not like it, since they don’t understand how it works 😂.</p>","timeToRead":3,"frontmatter":{"title":"JavaScript can do that?","unformattedDate":"2019-06-26T00:00:00.000Z","date":"Jun 26, 2019","path":"/js-can-do-that/","author":"Yaser Adel Mehraban","tags":["webdev","javascript","showdev"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAALABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAUBAwT/xAAWAQEBAQAAAAAAAAAAAAAAAAABAAL/2gAMAwEAAhADEAAAAVTLBfmkWg//xAAaEAEBAAIDAAAAAAAAAAAAAAACAQADEiIx/9oACAEBAAEFAjsowuUQ6rmpdE7xvv8A/8QAFREBAQAAAAAAAAAAAAAAAAAAABH/2gAIAQMBAT8BV//EABYRAQEBAAAAAAAAAAAAAAAAAAABEv/aAAgBAgEBPwGxl//EAB4QAAEDBAMAAAAAAAAAAAAAAAABERICITGRQWFx/9oACAEBAAY/AoozeErEqmdexcaONCn/xAAaEAEAAwEBAQAAAAAAAAAAAAABABEhMVFx/9oACAEBAAE/ISup6GWw3M0lyjW84iH2dDBqqb5m29Z//9oADAMBAAIAAwAAABBc7//EABcRAAMBAAAAAAAAAAAAAAAAAAABEXH/2gAIAQMBAT8QTjpg/8QAGBEAAgMAAAAAAAAAAAAAAAAAAAERMVH/2gAIAQIBAT8QY1ZLT//EABsQAQEAAwEBAQAAAAAAAAAAAAERACExQVGx/9oACAEBAAE/EHiCqiGydc66dRCwvDBW4sAK8wtBV2Q59TDiLaAn5juSosJ7n//Z"},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/b42bb6525b368ec041da166081559181/ec5b0/hdtew.jpg","srcSet":"/static/b42bb6525b368ec041da166081559181/ec5b0/hdtew.jpg 500w","sizes":"(min-width: 500px) 500px, 100vw"},"sources":[{"srcSet":"/static/b42bb6525b368ec041da166081559181/8e0eb/hdtew.webp 500w","type":"image/webp","sizes":"(min-width: 500px) 500px, 100vw"}]},"width":500,"height":283}}}}}},{"node":{"id":"9a746bea-89be-5b20-9358-1c21d605e305","html":"<p>For most companies, ranking #1 is like a blessing to their business. However, most of the web developers are not aware of what should be done to reach to that point.</p>\n<p>In this article we go through 10 simple steps to increase the ranking organically rather than paying search engines to do that for us. So, are you ready 🧐?</p>\n<!--more-->\n<h2 id=\"what-does-html-tags-tell-search-engines\" style=\"position:relative;\"><a href=\"#what-does-html-tags-tell-search-engines\" aria-label=\"what does html tags tell search engines permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What does HTML tags tell search engines?</h2>\n<p>Certain HTML tags tell search engines how to read your document properly and index it against specific keywords. In other words, when they crawl web, they will categorise your page with some keywords which then is surfaced when a user searches for them.</p>\n<p>Some of these tags also improve how visitors view your content in those search engines. And this is in addition to how social media uses content tags to show your articles like this for example 👇🏽.</p>\n<blockquote class=\"twitter-tweet\"><p lang=\"en\" dir=\"ltr\">Just a reminder to not miss my talk on micro apps and web components <a href=\"https://twitter.com/NDC_Conferences?ref_src=twsrc%5Etfw\">@NDC_Conferences</a> <a href=\"https://twitter.com/hashtag/NDCOslo?src=hash&amp;ref_src=twsrc%5Etfw\">#NDCOslo</a> 👇🏽<a href=\"https://t.co/JjBDfpAhmd\">https://t.co/JjBDfpAhmd</a></p>&mdash; Yaser A Mehraban👨🏽‍💻🎤☕️😴 (@yashints) <a href=\"https://twitter.com/yashints/status/1138194205912707073?ref_src=twsrc%5Etfw\">June 10, 2019</a></blockquote>\n<p>So let’s see what are these tags.</p>\n<h2 id=\"1-title-tag\" style=\"position:relative;\"><a href=\"#1-title-tag\" aria-label=\"1 title tag permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>1. Title tag</h2>\n<p>Perhaps one the most important tags is title. This is used as a label for your page and defines how search engines like Google and Bing see your page and show it in their search result.</p>\n<p>In most cases, this tag reflects the title of the article/page itself. This isn’t exactly a bad practice, but you’ll miss out on a few opportunities to score big in search engines like Google.</p>\n<p>The question which comes up is, does it have to be the same as keywords. And the answer is absolutely not. However, it’s good to make sure you’re not confusing the reader 😉. But this gives opportunity to expand on what your page is relevant to for the search engine. Title should be short anyway, so having different but related tags makes it accessible to a wider range of searches.</p>\n<p>A normal title tag is shown below:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"66592600388374600000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<title>Your Title Text for Search Engines</title>`, `66592600388374600000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>title</span><span class=\"token punctuation\">></span></span>Your Title Text for Search Engines<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>title</span><span class=\"token punctuation\">></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>It sounds very simple right? Well as simple as it looks, below are the points you have to consider when writing your title:</p>\n<ul>\n<li>Use only one title tag</li>\n<li>Try to create a unique title</li>\n<li>Don’t use your title keywords as your meta tags too (read further on tags)</li>\n<li>Make it relevant to content</li>\n<li>It’s good to keep it under 60 characters</li>\n<li>Try to not use stop words</li>\n<li>Show the branding last</li>\n<li>Make it readable</li>\n<li>Use dates, numbers and questions if relevant</li>\n</ul>\n<p>Here is an example of one of my articles being the first result on Google 😍:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 792px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 33.33333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAHABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAIF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB3QUD/8QAFhAAAwAAAAAAAAAAAAAAAAAAABAR/9oACAEBAAEFAir/xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAUEAEAAAAAAAAAAAAAAAAAAAAQ/9oACAEBAAY/An//xAAYEAACAwAAAAAAAAAAAAAAAAAAARAhYf/aAAgBAQABPyF0LEf/2gAMAwEAAgADAAAAEIAP/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPxA//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPxA//8QAGRAAAwEBAQAAAAAAAAAAAAAAAAERITGR/9oACAEBAAE/ENolUaRN6LVeH//Z'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Title helping SEO\"\n        title=\"\"\n        src=\"/static/e45ad815cf29e452ee3cdf555fcd8531/4dfa3/nestedfg.jpg\"\n        srcset=\"/static/e45ad815cf29e452ee3cdf555fcd8531/6f81f/nestedfg.jpg 270w,\n/static/e45ad815cf29e452ee3cdf555fcd8531/09d21/nestedfg.jpg 540w,\n/static/e45ad815cf29e452ee3cdf555fcd8531/4dfa3/nestedfg.jpg 792w\"\n        sizes=\"(max-width: 792px) 100vw, 792px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<h2 id=\"2-meta-description-tags\" style=\"position:relative;\"><a href=\"#2-meta-description-tags\" aria-label=\"2 meta description tags permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>2. Meta description tags</h2>\n<p>As I mentioned above, having description tags is really helpful to expose your page to a wider range of searches in addition to title.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"20190910526257520000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<meta\r\n  name=&quot;description&quot;\r\n  content=&quot;Key HTML tags to have better SEO.&quot;\r\n/>`, `20190910526257520000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>description<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Key HTML tags to have better SEO.<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>For example, above is a tag where someone tried to highlight “Key HTML tags” and “better SEO” phrases and also to be displayed in search results.</p>\n<div class=\"custom-block info\"><div class=\"custom-block-body\"><strong>Note:</strong> As of 2019, <a href=\"https://webmasters.googleblog.com/2017/06/better-snippets-for-your-users.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google has announced</a> that you shouldn’t focus too much on these as they will consider content first.</div></div>\n<h2 id=\"3-header-tags\" style=\"position:relative;\"><a href=\"#3-header-tags\" aria-label=\"3 header tags permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>3. Header tags</h2>\n<p>You should not underestimate header tags. They are often used to break up the content to make it easier to read. Imagine reading my article in one giant paragraph rather than these nicely separated pieces.</p>\n<p>It’s been discovered that about %55 of the users will spend <a href=\"https://blog.bufferapp.com/55-visitors-read-articles-15-seconds-less-focus-attention-not-clicks\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">15 seconds at most skimming your text</a>. In terms of SEO, header tags are what most search engines use to help determine segments of content and create <a href=\"https://www.greengeeks.com/blog/2017/02/14/why-should-you-want-your-site-to-be-in-the-google-featured-snippet/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">featured rich snippets</a>.</p>\n<p>These tags are as follows:</p>\n<ul>\n<li><code class=\"language-text\">&lt;h1>&lt;/h1></code> – Usually is used for webpage titles.</li>\n<li><code class=\"language-text\">&lt;h2>&lt;/h2></code> – Highlights the topic of the content following it.</li>\n<li><code class=\"language-text\">&lt;h3>&lt;/h3></code> – Reflects points in regards to the topic.</li>\n<li><code class=\"language-text\">&lt;h4>&lt;/h4></code> – Supports points from <code class=\"language-text\">&lt;h3></code>.</li>\n<li><code class=\"language-text\">&lt;h5>&lt;/h5></code> – Not often used, but great for supporting points of <code class=\"language-text\">&lt;h4></code></li>\n</ul>\n<h2 id=\"4-alt-tags-for-images\" style=\"position:relative;\"><a href=\"#4-alt-tags-for-images\" aria-label=\"4 alt tags for images permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>4. Alt tags for images</h2>\n<p>This is often the most important part of an image tag not just for SEO but also for accessibility. Unfortunately, search engines cannot determine what images are showing. That’s when the <code class=\"language-text\">alt</code> tag comes handy.</p>\n<p>For example:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"60965633664508890000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<img src=&quot;cute-puppy.jpg&quot; />`, `60965633664508890000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>cute-puppy.jpg<span class=\"token punctuation\">\"</span></span> <span class=\"token punctuation\">/></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Search engines wouldn’t know whether this image is showing a cute puppy or a cat. So adding <code class=\"language-text\">alt</code> tag would help them understand it and use it for categorisation.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"92469254280662350000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<img\r\n  src=&quot;cute-puppy.jpg&quot;\r\n  alt=&quot;Such a cute puppy&quot;\r\n/>`, `92469254280662350000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span>\r\n  <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>cute-puppy.jpg<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Such a cute puppy<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Above tag will correctly help search engines identify what the image is about. This will help to show this image when someone is trying to search for a cute puppy using Google images for example.</p>\n<h2 id=\"5-hyperlinks\" style=\"position:relative;\"><a href=\"#5-hyperlinks\" aria-label=\"5 hyperlinks permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>5. Hyperlinks</h2>\n<p>Although it doesn’t look like it, hyperlinks are vital, not only to external content, but also to your own content. To give you an example, when I posted my first of series on web performance on <a href=\"dev.to\">Dev community</a>, I had links to other articles on my site. That resulted in a spike of traffic to my site which was basically helping my natural traffic to go up and also help the search engine link these articles together.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1066px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 64.44444444444444%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAQBAgMF/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAe6k9RNCBf/EABkQAQACAwAAAAAAAAAAAAAAAAECEAMRE//aAAgBAQABBQKTohkelEQr/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAGBAAAgMAAAAAAAAAAAAAAAAAABECIDH/2gAIAQEABj8CZJ5X/8QAGhABAAIDAQAAAAAAAAAAAAAAEQAQASFRof/aAAgBAQABPyFHiMmvK3Mglf/aAAwDAQACAAMAAAAQk8//xAAWEQEBAQAAAAAAAAAAAAAAAAABEBH/2gAIAQMBAT8QTUZ//8QAFREBAQAAAAAAAAAAAAAAAAAAEBH/2gAIAQIBAT8Qp//EAB0QAQACAgIDAAAAAAAAAAAAAAEAESExQVGBkaH/2gAIAQEAAT8QBjQvELcFMcdK8TDBZs9QYMi/rcKNE//Z'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Sharing my article with links\"\n        title=\"\"\n        src=\"/static/62b5c673343759d87225a05f229b7ee9/f8402/htmlshare.jpg\"\n        srcset=\"/static/62b5c673343759d87225a05f229b7ee9/6f81f/htmlshare.jpg 270w,\n/static/62b5c673343759d87225a05f229b7ee9/09d21/htmlshare.jpg 540w,\n/static/62b5c673343759d87225a05f229b7ee9/f8402/htmlshare.jpg 1066w\"\n        sizes=\"(max-width: 1066px) 100vw, 1066px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<p>In its core, they are like you’re voting for other content, so use it in your benefit and make sure the linked content is relevant.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"91518969595780550000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<a\r\n  href=&quot;https://dev.to/yashints/pet-projects-the-secret-to-keep-yourself-updated-51e0&quot;\r\n>\r\n  My previous post about pet projects\r\n</a>`, `91518969595780550000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span>\r\n  <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://dev.to/yashints/pet-projects-the-secret-to-keep-yourself-updated-51e0<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">></span></span>\r\n  My previous post about pet projects\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>If for some reason you didn’t want the search engine to make a connection with what you’re linking to, consider using <code class=\"language-text\">rel=nofollow</code>. This tells the search engine to not link your current article with the link destination. In other words, you won’t help improve the domain authority of an external site.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"71053489441129300000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<a\r\n  href=&quot;https://dev.to/yashints/pet-projects-the-secret-to-keep-yourself-updated-51e0&quot;\r\n  rel=&quot;nofollow&quot;\r\n>\r\n  My previous post about pet projects\r\n</a>`, `71053489441129300000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span>\r\n  <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://dev.to/yashints/pet-projects-the-secret-to-keep-yourself-updated-51e0<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">rel</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>nofollow<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">></span></span>\r\n  My previous post about pet projects\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"6-open-graph-tags\" style=\"position:relative;\"><a href=\"#6-open-graph-tags\" aria-label=\"6 open graph tags permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>6. Open graph tags</h2>\n<p>These tags are great for showing nicely formatted version of your page on social media. You might have seen it before, but here is how my post appears on LinkedIn 👇🏽:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 67.03703703703704%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAIEAQP/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAG56MEOwf/EABsQAAIBBQAAAAAAAAAAAAAAAAIRAQADEBIT/9oACAEBAAEFArz1HEg45ilX/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAGRAAAgMBAAAAAAAAAAAAAAAAECEAAREx/9oACAEBAAY/AleToZ//xAAcEAEAAgIDAQAAAAAAAAAAAAABABEhMRBBUXH/2gAIAQEAAT8hoLgO5ftP3gGMhmIVryVn/9oADAMBAAIAAwAAABADD//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EABwQAQACAgMBAAAAAAAAAAAAAAERIQAxEEGhcf/aAAgBAQABPxCcKyjz3DKU24hXEEVJE2Y6TEJpZ8wPqc//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"open graph tags\"\n        title=\"\"\n        src=\"/static/97ab6576fd915e1371c9cbc01b57d569/47311/ndc.jpg\"\n        srcset=\"/static/97ab6576fd915e1371c9cbc01b57d569/6f81f/ndc.jpg 270w,\n/static/97ab6576fd915e1371c9cbc01b57d569/09d21/ndc.jpg 540w,\n/static/97ab6576fd915e1371c9cbc01b57d569/47311/ndc.jpg 1080w,\n/static/97ab6576fd915e1371c9cbc01b57d569/40cc6/ndc.jpg 1119w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<p>Here is an example of an open graph tag:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"41178336310042420000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<meta\r\n  name=&quot;og:title&quot;\r\n  property=&quot;og:title&quot;\r\n  content=&quot;The Title of Your Article&quot;\r\n/>`, `41178336310042420000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>og:title<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">property</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>og:title<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>The Title of Your Article<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Now if this article is shared on something like Facebook, the social site will pull the title directly from this tag. As you saw from the tweet I showed above, open graph supports things like descriptions and images as well. It simply gives you customization options if your webpage is shared on social media.</p>\n<h2 id=\"7-robots-tag\" style=\"position:relative;\"><a href=\"#7-robots-tag\" aria-label=\"7 robots tag permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>7. Robots Tag</h2>\n<p>This tag is useful if you want to prevent your page/article from being indexed. These can stop crawlers from sites like Google or Bing from accessing the content. You might now ask why would you want that?</p>\n<p>Some articles might not be the most influencing for rankings. There are veraity of reasons why you might want this, but let’s say you have an article which lacks quality and you want to get some user’s opinion before it appears on any search engine results.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"69864993464927870000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<meta name=&quot;robots&quot; content=&quot;noindex, nofollow&quot; />`, `69864993464927870000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span> <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>robots<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>noindex, nofollow<span class=\"token punctuation\">\"</span></span> <span class=\"token punctuation\">/></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<h2 id=\"8-canonical-tags\" style=\"position:relative;\"><a href=\"#8-canonical-tags\" aria-label=\"8 canonical tags permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>8. Canonical tags</h2>\n<p>A <a href=\"https://moz.com/learn/seo/canonicalization\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">canonical tag</a> is great for organizing your content and prioritizing one web page over a duplicate web page. Just to give you an example, I always like to post my posts on <a href=\"https://yashints.dev\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">my website</a> first before I post it somewhere else.</p>\n<p>I do it because of a couple of reasons. The most important one is that the reach might be higher on those platforms like <a href=\"dev.to\">Dev.to</a>. However, I want search engines to know that this post is not a separate one, and in fact it is a copy of what is published on my website first. In other words, it is a way of telling search engines that a specific URL represents the master copy of a page.</p>\n<p>Another reason why you should use this tag is that search engines might crawl your website using any of these URL forms:</p>\n<ul>\n<li><a href=\"http://www.yashints.dev\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http://www.yashints.dev</a></li>\n<li><a href=\"https://www.yashints.dev\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://www.yashints.dev</a></li>\n<li><a href=\"http://yashints.dev\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http://yashints.dev</a></li>\n<li><a href=\"http://yashints.dev/index.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http://yashints.dev/index.html</a></li>\n<li><a href=\"http://yashints.dev/index.html?param=value\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http://yashints.dev/index.html?param=value</a></li>\n</ul>\n<p>To a human, all of these URLs represent a single page. To a crawler, though, every single one of these URLs is a unique <code class=\"language-text\">page</code>. Even in this limited example, we can see there are five copies of the homepage in play. In reality, though, this is just a small sample of the variations you might encounter.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"39915987738481975000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<link\r\n  rel=&quot;canonical&quot;\r\n  href=&quot;http://yashints.dev/index.html?param=value&quot;\r\n/>`, `39915987738481975000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>link</span>\r\n  <span class=\"token attr-name\">rel</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>canonical<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>http://yashints.dev/index.html?param=value<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>So by putting above tag on my home page, I can tell search engines that this URL is representing the same and not a separate page.</p>\n<p><a href=\"https://yoast.com/rel-canonical/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Here is a good article</a> going more deep into canonical tags.</p>\n<h2 id=\"9-responsive-site-meta-tags\" style=\"position:relative;\"><a href=\"#9-responsive-site-meta-tags\" aria-label=\"9 responsive site meta tags permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>9. Responsive site meta tags</h2>\n<p>Let’s first go through the fact that more than %80 of traffic in China comes through mobile devices. In Australia this number is %56. These numbers show us how important it is to pay attention to responsive design.</p>\n<p>For the same reason it’s important to let the search engines know that this site has responsive design available. This will ensure that the page is surfaces if a user is searching through a mobile device.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"208804965463405000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<meta\r\n  name=&quot;viewport&quot;\r\n  content=&quot;width=device-width, initial-scale=1&quot;\r\n/>`, `208804965463405000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>viewport<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>width=device-width, initial-scale=1<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Above tag is the minimum you will need to let search engines know your site is mobile friendly. It’s important to note that <strong>Google</strong> puts emphasis on websites that are mobile-friendly. And if you don’t have something readily available that people can view from a hand-held device, it will reflect your rankings in search.</p>\n<h2 id=\"10-twitter-cards\" style=\"position:relative;\"><a href=\"#10-twitter-cards\" aria-label=\"10 twitter cards permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>10. Twitter cards</h2>\n<p>Apart from open graph tags, <a href=\"twitter.com\">Twitter</a> has <a href=\"https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/markup\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">its own tags</a>. Now that tweets can exceed historic 140 characters, these cards are a nice extension that allows your tweets to stand out in the crowd of common text.</p>\n<h3 id=\"here-are-a-few-of-them\" style=\"position:relative;\"><a href=\"#here-are-a-few-of-them\" aria-label=\"here are a few of them permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Here are a few of them:</h3>\n<h4 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h4>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"94745225653520500000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<meta name=&quot;twitter:card&quot; content=&quot;summary&quot; />\r\n<meta name=&quot;twitter:site&quot; content=&quot;@flickr&quot; />\r\n<meta\r\n  name=&quot;twitter:title&quot;\r\n  content=&quot;Small Island Developing States Photo Submission&quot;\r\n/>\r\n<meta\r\n  name=&quot;twitter:description&quot;\r\n  content=&quot;View the album on Flickr.&quot;\r\n/>\r\n<meta\r\n  name=&quot;twitter:image&quot;\r\n  content=&quot;https://farm6.staticflickr.com/5510/14338202952_93595258ff_z.jpg&quot;\r\n/>`, `94745225653520500000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span> <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:card<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>summary<span class=\"token punctuation\">\"</span></span> <span class=\"token punctuation\">/></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span> <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:site<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>@flickr<span class=\"token punctuation\">\"</span></span> <span class=\"token punctuation\">/></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:title<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Small Island Developing States Photo Submission<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:description<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>View the album on Flickr.<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:image<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://farm6.staticflickr.com/5510/14338202952_93595258ff_z.jpg<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Example:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 80.37037037037037%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAQABQDASIAAhEBAxEB/8QAGAAAAgMAAAAAAAAAAAAAAAAAAAQBAgX/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAHauLjRAf/EABsQAAIBBQAAAAAAAAAAAAAAAAABAxASISIx/9oACAEBAAEFAnqYoyWO9Ln/xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAaEAACAgMAAAAAAAAAAAAAAAABEAAREiJR/9oACAEBAAY/ApT1OJ6v/8QAGRABAQEBAQEAAAAAAAAAAAAAAREAIRBR/9oACAEBAAE/IZji1mIeu/PBUzRbIQG//9oADAMBAAIAAwAAABDTD//EABURAQEAAAAAAAAAAAAAAAAAAAEQ/9oACAEDAQE/ECf/xAAVEQEBAAAAAAAAAAAAAAAAAAABEP/aAAgBAgEBPxBn/8QAGxABAQEAAwEBAAAAAAAAAAAAEQEAITFBUaH/2gAIAQEAAT8QN5oi83VCEKL5g3EInb83DiKTbL+d5uWSLW7/2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Twitter card\"\n        title=\"\"\n        src=\"/static/7c234f437192878835a8f86a4386c653/47311/twittercard.jpg\"\n        srcset=\"/static/7c234f437192878835a8f86a4386c653/6f81f/twittercard.jpg 270w,\n/static/7c234f437192878835a8f86a4386c653/09d21/twittercard.jpg 540w,\n/static/7c234f437192878835a8f86a4386c653/47311/twittercard.jpg 1080w,\n/static/7c234f437192878835a8f86a4386c653/e4b8a/twittercard.jpg 1207w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<h4 id=\"player\" style=\"position:relative;\"><a href=\"#player\" aria-label=\"player permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Player</h4>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"20715949267641197000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<meta name=&quot;twitter:card&quot; content=&quot;player&quot; />\r\n<meta\r\n  name=&quot;twitter:title&quot;\r\n  content=&quot;Bison in Yellowstone&quot;\r\n/>\r\n<meta\r\n  name=&quot;twitter:site&quot;\r\n  content=&quot;@BrightcoveLearn&quot;\r\n/>\r\n<meta\r\n  name=&quot;twitter:description&quot;\r\n  content=&quot;Bison walking in Yellowstone National Park.&quot;\r\n/>\r\n<meta\r\n  name=&quot;twitter:player&quot;\r\n  content=&quot;https://solutions.brightcove.com/bcls/twittercards/bison.html&quot;\r\n/>\r\n<meta name=&quot;twitter:player:width&quot; content=&quot;360&quot; />\r\n<meta\r\n  name=&quot;twitter:player:height&quot;\r\n  content=&quot;200&quot;\r\n/>\r\n<meta\r\n  name=&quot;twitter:image&quot;\r\n  content=&quot;https://solutions.brightcove.com/bcls/twittercards/bison.jpg&quot;\r\n/>`, `20715949267641197000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span> <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:card<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>player<span class=\"token punctuation\">\"</span></span> <span class=\"token punctuation\">/></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:title<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Bison in Yellowstone<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:site<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>@BrightcoveLearn<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:description<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Bison walking in Yellowstone National Park.<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:player<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://solutions.brightcove.com/bcls/twittercards/bison.html<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span> <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:player:width<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>360<span class=\"token punctuation\">\"</span></span> <span class=\"token punctuation\">/></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:player:height<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>200<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>meta</span>\r\n  <span class=\"token attr-name\">name</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>twitter:image<span class=\"token punctuation\">\"</span></span>\r\n  <span class=\"token attr-name\">content</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://solutions.brightcove.com/bcls/twittercards/bison.jpg<span class=\"token punctuation\">\"</span></span>\r\n<span class=\"token punctuation\">/></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Example:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 38.888888888888886%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAIABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAQC/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAABuvDQP//EABcQAQADAAAAAAAAAAAAAAAAAAEDEBT/2gAIAQEAAQUCGTRX/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAGBAAAgMAAAAAAAAAAAAAAAAAARIQEXL/2gAIAQEABj8CWimZ/8QAGhAAAgIDAAAAAAAAAAAAAAAAADEBIUFRYf/aAAgBAQABPyGMqrBbL4Qf/9oADAMBAAIAAwAAABCAD//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EABsQAQACAgMAAAAAAAAAAAAAAAEAIRExQVGR/9oACAEBAAE/EE5JESDApv3A4HqBC5//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Twitter player card\"\n        title=\"\"\n        src=\"/static/3aa47f126fab179a7c066a24da93a5c1/47311/video.jpg\"\n        srcset=\"/static/3aa47f126fab179a7c066a24da93a5c1/6f81f/video.jpg 270w,\n/static/3aa47f126fab179a7c066a24da93a5c1/09d21/video.jpg 540w,\n/static/3aa47f126fab179a7c066a24da93a5c1/47311/video.jpg 1080w,\n/static/3aa47f126fab179a7c066a24da93a5c1/62f39/video.jpg 1202w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<p>For more info on these tags, visit their <a href=\"https://developer.twitter.com/en/docs/tweets/optimize-with-cards/overview/markup\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">official documentation</a>.</p>\n<h2 id=\"so-no-keyword-tags\" style=\"position:relative;\"><a href=\"#so-no-keyword-tags\" aria-label=\"so no keyword tags permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>So no keyword tags?</h2>\n<p>You might wondering why I didn’t mention keyword tags. That’s because most search engines like Google use content to categorise the page. So having them doesn’t add any value that much and in fact to many of them just adds extra weight to your pages.</p>\n<h2 id=\"summary-1\" style=\"position:relative;\"><a href=\"#summary-1\" aria-label=\"summary 1 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>You now know 10 tips to improve your SEO organically and save some money. So head to a bar or coffee shop and spend it responsibly 😉.</p>\n<p>Another tip I forgot to mention was around people who use a SPA framework. If you want to have SEO for your site, you will need to define some critical paths (i.e. homepage) and create a server side rendered of that page which gets replaced by the normal route on client side. This way crawlers would be able to index your statically generated file while your end users still have the benefit of fast interactions on client side.</p>\n<p>Till next post 👋🏼.</p>","timeToRead":8,"frontmatter":{"title":"Boost your ranking with these 10 tips","unformattedDate":"2019-06-11T00:00:00.000Z","date":"Jun 11, 2019","path":"/seo-tips/","author":"Yaser Adel Mehraban","tags":["webdev","seo","showdev"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAARABQDASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAAAAECAwX/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAHuog0BWoaA/8QAGBAAAgMAAAAAAAAAAAAAAAAAARAAAhH/2gAIAQEAAQUCM1WZf//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8BH//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8BH//EABQQAQAAAAAAAAAAAAAAAAAAADD/2gAIAQEABj8CH//EABsQAAICAwEAAAAAAAAAAAAAAAABMUEQIWFx/9oACAEBAAE/IdKFxikC8FBUUiP/2gAMAwEAAgADAAAAECAAAP/EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8QH//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8QH//EAB4QAAICAQUBAAAAAAAAAAAAAAABETEhQVFhcZGx/9oACAEBAAE/EKYkuxu70WVOS30Ea0elUpJ8FxV2VP/Z"},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/ade4d6c9fffc2fdc0b7e342f5b1ca365/061d6/seo.jpg","srcSet":"/static/ade4d6c9fffc2fdc0b7e342f5b1ca365/061d6/seo.jpg 546w","sizes":"(min-width: 546px) 546px, 100vw"},"sources":[{"srcSet":"/static/ade4d6c9fffc2fdc0b7e342f5b1ca365/d4db1/seo.webp 546w","type":"image/webp","sizes":"(min-width: 546px) 546px, 100vw"}]},"width":546,"height":469}}}}}},{"node":{"id":"edd61449-211d-533a-8170-5752eb355a9f","html":"<p>Let’s face the reality, we can’t live without passwords these days. In fact our entire online life is depending on them. But with passwords, comes heaps of problems not only for users, but also for us developers.</p>\n<!--more-->\n<h1 id=\"a-bitter-fact\" style=\"position:relative;\"><a href=\"#a-bitter-fact\" aria-label=\"a bitter fact permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>A bitter fact</h1>\n<p>Most people have a weak password (and probably the same) used for many websites they’re member of. Social media, email, productivity tools, you name it, they all have different policies around passwords and majority of users find a way to bypass it using a weak password, or a strong one written on a post it 🤷🏽‍♂️.</p>\n<p>In fact 81% of all data breaches that happen due to hacking, <a href=\"https://www.verizonenterprise.com/resources/reports/2017_dbir_en_xg.pdf\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">leverage stolen or weak passwords</a>.</p>\n<h1 id=\"there-is-a-better-way\" style=\"position:relative;\"><a href=\"#there-is-a-better-way\" aria-label=\"there is a better way permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>There is a better way</h1>\n<p>But thanks to great efforts from <a href=\"https://www.w3.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">W3C</a> and <a href=\"https://fidoalliance.org\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">FIDO</a>, we’re not bound to use passwords for everything. Web Authentication API, aka <code class=\"language-text\">WebAuthn</code> is a fairly <a href=\"https://w3c.github.io/webauthn/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">new specification</a> which is introducing a new way of authentication without passwords, and also alongside them.</p>\n<p>Google, Microsoft, Yubico and other big names in the industry are all part of the contributors to get this spec widespread. This API allows servers to register and authenticate users using public key cryptography instead of passwords.</p>\n<p>Windows Hello, Apple’s Touch ID, Yubikey devices, are all examples of a different type of authentication mechanism which doesn’t require passwords. They use biometrics or hardware devices to be able to achieve this.</p>\n<h1 id=\"how-it-works\" style=\"position:relative;\"><a href=\"#how-it-works\" aria-label=\"how it works permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How it works</h1>\n<p>From 1000ft, instead of using a password, you will use a <a href=\"https://en.wikipedia.org/wiki/Public-key_cryptography\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">key pair (public and private)</a> which is generated for a website.</p>\n<p>The private key is stored securely on user’s device, whereas the public key along with a randomly generated credential ID is sent to a web server to be stored and used later for authenticating that particular user.</p>\n<p>Overall, WebAuthn relies on three major parties:</p>\n<ul>\n<li>Authenticator (the device which is doing the authentication and verification)</li>\n<li>Relying party (the web application owner)</li>\n<li>Browser’s Web Authentication API</li>\n</ul>\n<p>The flow is fairly simple, first step is registration, then it would be authentication.</p>\n<h2 id=\"registration-a-credential\" style=\"position:relative;\"><a href=\"#registration-a-credential\" aria-label=\"registration a credential permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Registration a credential</h2>\n<p>Same as password authentication flows where the web server usually provides a form for user to enter their password which is sent back to the server for verification.</p>\n<p>With WebAuthn, it’s fairly similar, but instead of asking for a password, the relying party asks for a public key.</p>\n<table>\n<thead>\n<tr>\n<th align=\"center\"><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 368px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/124aae1c593680a7f43623f2843b9cb3/7d8cb/registration.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 94.81481481481482%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAATABQDASIAAhEBAxEB/8QAGQABAAIDAAAAAAAAAAAAAAAAAAECAwQF/8QAFwEAAwEAAAAAAAAAAAAAAAAAAAEDAv/aAAwDAQACEAMQAAAB7MKudwzFYg9gU1//xAAZEAACAwEAAAAAAAAAAAAAAAAAAQISMRH/2gAIAQEAAQUCt0syrZPSz7HBZ//EABcRAAMBAAAAAAAAAAAAAAAAAAAQESH/2gAIAQMBAT8Bpj//xAAYEQACAwAAAAAAAAAAAAAAAAAAARARIf/aAAgBAgEBPwGmbP8A/8QAHRAAAQMFAQAAAAAAAAAAAAAAABExQQEQIXGhsf/aAAgBAQAGPwLHg/BVJJGK7v8A/8QAHRAAAgEEAwAAAAAAAAAAAAAAAAERMUFRYYGR8f/aAAgBAQABPyGs2aScDYMx3DxEaLnK0XJyI2+ymf/aAAwDAQACAAMAAAAQYN+D/8QAGBEAAgMAAAAAAAAAAAAAAAAAAAEQETH/2gAIAQMBAT8QbXNYf//EABgRAAMBAQAAAAAAAAAAAAAAAAABMRGh/9oACAECAQE/EFheCCFD/8QAHhABAQEAAgEFAAAAAAAAAAAAAREAIUExUWHR4fH/2gAIAQEAAT8QvmUA23fsNAGDoI8YUnp68aEDxt7wBUKDHnUu+Xtp+384wPbf/9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Registration using WebAuthn\"\n        title=\"\"\n        src=\"/static/124aae1c593680a7f43623f2843b9cb3/7d8cb/registration.jpg\"\n        srcset=\"/static/124aae1c593680a7f43623f2843b9cb3/6f81f/registration.jpg 270w,\n/static/124aae1c593680a7f43623f2843b9cb3/7d8cb/registration.jpg 368w\"\n        sizes=\"(max-width: 368px) 100vw, 368px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align=\"center\"><em>Image from WebAuthn.io</em></td>\n</tr>\n</tbody>\n</table>\n<p>When prompting the user for a credential, the <code class=\"language-text\">navigator.credentials.create()</code> is used:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"21378888829676024000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const credential = await navigator.credentials.create(\r\n  {\r\n    publicKey: publicKeyCredentialCreationOptions,\r\n  }\r\n)`, `21378888829676024000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token keyword\">const</span> credential <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> navigator<span class=\"token punctuation\">.</span>credentials<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span>\r\n  <span class=\"token punctuation\">{</span>\r\n    publicKey<span class=\"token operator\">:</span> publicKeyCredentialCreationOptions<span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">)</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>In case you’re wondering what does the <code class=\"language-text\">publicKeyCredentialCreationOptions</code> looks like, it contains a bunch of mandatory and optional fields:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"6032662695319746000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const publicKeyCredentialCreationOptions = {\r\n  challenge: Uint8Array.from(\r\n    randomStringFromServer,\r\n    c => c.charCodeAt(0)\r\n  ),\r\n  rp: {\r\n    name: 'Google',\r\n    id: 'accounts.google.com',\r\n  },\r\n  user: {\r\n    id: Uint8Array.from('5T9AFCUZSL8', c =>\r\n      c.charCodeAt(0)\r\n    ),\r\n    name: 'me@yashints.dev',\r\n    displayName: 'Yaser',\r\n  },\r\n  pubKeyCredParams: [\r\n    { alg: -7, type: 'public-key' },\r\n  ],\r\n  authenticatorSelection: {\r\n    authenticatorAttachment: 'cross-platform',\r\n  },\r\n  timeout: 60000,\r\n  attestation: 'direct',\r\n}`, `6032662695319746000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token keyword\">const</span> publicKeyCredentialCreationOptions <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  challenge<span class=\"token operator\">:</span> Uint8Array<span class=\"token punctuation\">.</span><span class=\"token function\">from</span><span class=\"token punctuation\">(</span>\r\n    randomStringFromServer<span class=\"token punctuation\">,</span>\r\n    c <span class=\"token operator\">=></span> c<span class=\"token punctuation\">.</span><span class=\"token function\">charCodeAt</span><span class=\"token punctuation\">(</span><span class=\"token number\">0</span><span class=\"token punctuation\">)</span>\r\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n  rp<span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    name<span class=\"token operator\">:</span> <span class=\"token string\">'Google'</span><span class=\"token punctuation\">,</span>\r\n    id<span class=\"token operator\">:</span> <span class=\"token string\">'accounts.google.com'</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  user<span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    id<span class=\"token operator\">:</span> Uint8Array<span class=\"token punctuation\">.</span><span class=\"token function\">from</span><span class=\"token punctuation\">(</span><span class=\"token string\">'5T9AFCUZSL8'</span><span class=\"token punctuation\">,</span> c <span class=\"token operator\">=></span>\r\n      c<span class=\"token punctuation\">.</span><span class=\"token function\">charCodeAt</span><span class=\"token punctuation\">(</span><span class=\"token number\">0</span><span class=\"token punctuation\">)</span>\r\n    <span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n    name<span class=\"token operator\">:</span> <span class=\"token string\">'me@yashints.dev'</span><span class=\"token punctuation\">,</span>\r\n    displayName<span class=\"token operator\">:</span> <span class=\"token string\">'Yaser'</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  pubKeyCredParams<span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\r\n    <span class=\"token punctuation\">{</span> alg<span class=\"token operator\">:</span> <span class=\"token operator\">-</span><span class=\"token number\">7</span><span class=\"token punctuation\">,</span> type<span class=\"token operator\">:</span> <span class=\"token string\">'public-key'</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\r\n  authenticatorSelection<span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    authenticatorAttachment<span class=\"token operator\">:</span> <span class=\"token string\">'cross-platform'</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  timeout<span class=\"token operator\">:</span> <span class=\"token number\">60000</span><span class=\"token punctuation\">,</span>\r\n  attestation<span class=\"token operator\">:</span> <span class=\"token string\">'direct'</span><span class=\"token punctuation\">,</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p><code class=\"language-text\">challenge</code>: The most important part in the options is the challenge. It is a randomly generated bytes on the server which is used to prevent reply attacks.</p>\n<p><code class=\"language-text\">rp</code>: Which stands for relying party, is the web server which user is trying to register to.</p>\n<p><code class=\"language-text\">user</code>: This is the end user who is registering to a service. The <code class=\"language-text\">id</code> is used to associate the public key to that user, but is suggested not be a personally identifying information.</p>\n<p><code class=\"language-text\">pubKeyCredPrams</code>: Specifies which types of public key are acceptable by the server.</p>\n<p><code class=\"language-text\">authenticatorSelection</code>: Is an optional field which helps relying parties to put further restrictions on authenticators allowed for registration. The possible values (<code class=\"language-text\">platform</code> like Windows Hello, or <code class=\"language-text\">cross-platform</code> like Yubikey) can be found <a href=\"https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-authenticatorselection\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">on the spec</a>.</p>\n<p><code class=\"language-text\">timeout</code>: The time in millisecond that the user has to respond to the registration prompt.</p>\n<p><code class=\"language-text\">attestation</code>: This is returned from the authenticator and contains information that can used to track the user. It indicates how important the attestation is to this registration event. For example, if <code class=\"language-text\">none</code> is used, it means server doesn’t care about it. <code class=\"language-text\">indirect</code> means server will allow for anonymised attestation data. <code class=\"language-text\">direct</code> means that server requires the data from authenticator. In general this is regarding privacy of users when registration is happening.</p>\n<p>The object which is returned from the <code class=\"language-text\">create()</code> call, contains a public key and other attributes which are used to validate the user:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"60339684956742530000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`console.log(credential);\r\n\r\nPublicKeyCredential {\r\n    id: 'ADSUllKQmbqdGtpu4sjseh4cg2TxSvrbcHDTBsv4NSSX9...',\r\n    rawId: ArrayBuffer(59),\r\n    response: AuthenticatorAttestationResponse {\r\n        clientDataJSON: ArrayBuffer(121),\r\n        attestationObject: ArrayBuffer(306),\r\n    },\r\n    type: 'public-key'\r\n}`, `60339684956742530000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token builtin\">console</span><span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>credential<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\nPublicKeyCredential <span class=\"token punctuation\">{</span>\r\n    id<span class=\"token operator\">:</span> <span class=\"token string\">'ADSUllKQmbqdGtpu4sjseh4cg2TxSvrbcHDTBsv4NSSX9...'</span><span class=\"token punctuation\">,</span>\r\n    rawId<span class=\"token operator\">:</span> <span class=\"token function\">ArrayBuffer</span><span class=\"token punctuation\">(</span><span class=\"token number\">59</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n    response<span class=\"token operator\">:</span> AuthenticatorAttestationResponse <span class=\"token punctuation\">{</span>\r\n        clientDataJSON<span class=\"token operator\">:</span> <span class=\"token function\">ArrayBuffer</span><span class=\"token punctuation\">(</span><span class=\"token number\">121</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n        attestationObject<span class=\"token operator\">:</span> <span class=\"token function\">ArrayBuffer</span><span class=\"token punctuation\">(</span><span class=\"token number\">306</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n    type<span class=\"token operator\">:</span> <span class=\"token string\">'public-key'</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"verifying-the-registration-data-by-relying-party\" style=\"position:relative;\"><a href=\"#verifying-the-registration-data-by-relying-party\" aria-label=\"verifying the registration data by relying party permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Verifying the registration data by relying party</h2>\n<p>Once the public key is received along with other properties of registration data to the server, <a href=\"https://w3c.github.io/webauthn/#registering-a-new-credential\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">there is a procedure</a> to validate this data.</p>\n<p>Of course the implementation depends on what language you’re using, but, there are some examples out there if you want to have an idea how to implement these steps. Duo Labs has provided full implementation in <a href=\"https://github.com/duo-labs/webauthn\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Go</a> and <a href=\"https://github.com/duo-labs/py_webauthn\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Python</a>.</p>\n<h2 id=\"authenticating-with-webauthn\" style=\"position:relative;\"><a href=\"#authenticating-with-webauthn\" aria-label=\"authenticating with webauthn permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Authenticating with WebAuthn</h2>\n<p>After completing the registration, the user is able to be to authenticate to the site. During registration user has obtained an assertion which indicates they have the private key. This contains a signature using the mentioned private key. Web server uses the public key during registration to verify this.</p>\n<p>The authentication flow looks something like this:</p>\n<table>\n<thead>\n<tr>\n<th align=\"center\"><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 352px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/ce5d7c2c1ccf85c8876d19bd52b9d5f7/e5a29/auth.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 143.33333333333334%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAdABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAgADBf/EABYBAQEBAAAAAAAAAAAAAAAAAAECA//aAAwDAQACEAMQAAAB7JRM3Oqs89TmOdb/AP/EABoQAAIDAQEAAAAAAAAAAAAAAAABAhESMQP/2gAIAQEAAQUCcjQkT6Wj0EZQ4soXP//EABYRAQEBAAAAAAAAAAAAAAAAAAEAEf/aAAgBAwEBPwFsJLC//8QAGBEBAQADAAAAAAAAAAAAAAAAABEBISL/2gAIAQIBAT8B6bXKv//EABsQAAIBBQAAAAAAAAAAAAAAAAAxEQEQICEy/9oACAEBAAY/AtVGTIhY9Dt//8QAHBABAAMBAAMBAAAAAAAAAAAAAQARIUExUXGR/9oACAEBAAE/IT+LTkL9fkVvpstQA9gPTAShMlClv5cRmMG3d2aNa3L+88E//9oADAMBAAIAAwAAABDswY//xAAZEQACAwEAAAAAAAAAAAAAAAAAARARIVH/2gAIAQMBAT8QbYLGLkf/xAAYEQADAQEAAAAAAAAAAAAAAAAAAREhQf/aAAgBAgEBPxCcQoaXgmh//8QAHRABAQADAAIDAAAAAAAAAAAAAREAITEQQVFhgf/aAAgBAQABPxDffUBUcfS34Mijjj6wQM617xUJHunIKjSXmCid1EGaYOvbcMbp1vAGzpU4fB4UoS1Duf/Z'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Authentication process\"\n        title=\"\"\n        src=\"/static/ce5d7c2c1ccf85c8876d19bd52b9d5f7/e5a29/auth.jpg\"\n        srcset=\"/static/ce5d7c2c1ccf85c8876d19bd52b9d5f7/6f81f/auth.jpg 270w,\n/static/ce5d7c2c1ccf85c8876d19bd52b9d5f7/e5a29/auth.jpg 352w\"\n        sizes=\"(max-width: 352px) 100vw, 352px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align=\"center\"><em>Image from WebAuthn.io</em></td>\n</tr>\n</tbody>\n</table>\n<p>The <code class=\"language-text\">navigator.credentials.get()</code> method is called to generate an assertion to prove the user own the private key. This will retrieve the credential generated during registration with a signature included.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"60049081439530830000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const credential = await navigator.credentials.get(\r\n  {\r\n    publicKey: publicKeyCredentialRequestOptions,\r\n  }\r\n)`, `60049081439530830000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token keyword\">const</span> credential <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> navigator<span class=\"token punctuation\">.</span>credentials<span class=\"token punctuation\">.</span><span class=\"token function\">get</span><span class=\"token punctuation\">(</span>\r\n  <span class=\"token punctuation\">{</span>\r\n    publicKey<span class=\"token operator\">:</span> publicKeyCredentialRequestOptions<span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">)</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>The <code class=\"language-text\">publicKeyCredentialRequestOptions</code> object contains a number of mandatory and optional properties which is specified by the server:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"12171365176859173000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const publicKeyCredentialRequestOptions = {\r\n  challenge: Uint8Array.from(\r\n    randomStringFromServer,\r\n    c => c.charCodeAt(0)\r\n  ),\r\n  allowCredentials: [\r\n    {\r\n      id: Uint8Array.from(credentialId, c =>\r\n        c.charCodeAt(0)\r\n      ),\r\n      type: 'public-key',\r\n      transports: ['usb', 'ble', 'nfc'],\r\n    },\r\n  ],\r\n  timeout: 60000,\r\n}`, `12171365176859173000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token keyword\">const</span> publicKeyCredentialRequestOptions <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  challenge<span class=\"token operator\">:</span> Uint8Array<span class=\"token punctuation\">.</span><span class=\"token function\">from</span><span class=\"token punctuation\">(</span>\r\n    randomStringFromServer<span class=\"token punctuation\">,</span>\r\n    c <span class=\"token operator\">=></span> c<span class=\"token punctuation\">.</span><span class=\"token function\">charCodeAt</span><span class=\"token punctuation\">(</span><span class=\"token number\">0</span><span class=\"token punctuation\">)</span>\r\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n  allowCredentials<span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\r\n    <span class=\"token punctuation\">{</span>\r\n      id<span class=\"token operator\">:</span> Uint8Array<span class=\"token punctuation\">.</span><span class=\"token function\">from</span><span class=\"token punctuation\">(</span>credentialId<span class=\"token punctuation\">,</span> c <span class=\"token operator\">=></span>\r\n        c<span class=\"token punctuation\">.</span><span class=\"token function\">charCodeAt</span><span class=\"token punctuation\">(</span><span class=\"token number\">0</span><span class=\"token punctuation\">)</span>\r\n      <span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n      type<span class=\"token operator\">:</span> <span class=\"token string\">'public-key'</span><span class=\"token punctuation\">,</span>\r\n      transports<span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span><span class=\"token string\">'usb'</span><span class=\"token punctuation\">,</span> <span class=\"token string\">'ble'</span><span class=\"token punctuation\">,</span> <span class=\"token string\">'nfc'</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\r\n  timeout<span class=\"token operator\">:</span> <span class=\"token number\">60000</span><span class=\"token punctuation\">,</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>The most interesting part in this object is the transport property. The server can optionally indicate what transports it prefers, like USB, NFC, and Bluetooth.</p>\n<p>The returned object is a <code class=\"language-text\">PublicKeyCredential</code> object, but slightly different from the previous one from registration.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"5434912977390005000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`console.log(assertion);\r\n\r\nPublicKeyCredential {\r\n    id: 'SSX9lKQmbqdGtbcHDTBsvpu4sjseh4cg2TxSvr4ADSUlN...',\r\n    rawId: ArrayBuffer(59),\r\n    response: AuthenticatorAssertionResponse {\r\n        authenticatorData: ArrayBuffer(191),\r\n        clientDataJSON: ArrayBuffer(118),\r\n        signature: ArrayBuffer(70),\r\n        userHandle: ArrayBuffer(10),\r\n    },\r\n    type: 'public-key'\r\n}`, `5434912977390005000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token builtin\">console</span><span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>assertion<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\nPublicKeyCredential <span class=\"token punctuation\">{</span>\r\n    id<span class=\"token operator\">:</span> <span class=\"token string\">'SSX9lKQmbqdGtbcHDTBsvpu4sjseh4cg2TxSvr4ADSUlN...'</span><span class=\"token punctuation\">,</span>\r\n    rawId<span class=\"token operator\">:</span> <span class=\"token function\">ArrayBuffer</span><span class=\"token punctuation\">(</span><span class=\"token number\">59</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n    response<span class=\"token operator\">:</span> AuthenticatorAssertionResponse <span class=\"token punctuation\">{</span>\r\n        authenticatorData<span class=\"token operator\">:</span> <span class=\"token function\">ArrayBuffer</span><span class=\"token punctuation\">(</span><span class=\"token number\">191</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n        clientDataJSON<span class=\"token operator\">:</span> <span class=\"token function\">ArrayBuffer</span><span class=\"token punctuation\">(</span><span class=\"token number\">118</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n        signature<span class=\"token operator\">:</span> <span class=\"token function\">ArrayBuffer</span><span class=\"token punctuation\">(</span><span class=\"token number\">70</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n        userHandle<span class=\"token operator\">:</span> <span class=\"token function\">ArrayBuffer</span><span class=\"token punctuation\">(</span><span class=\"token number\">10</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n    type<span class=\"token operator\">:</span> <span class=\"token string\">'public-key'</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>For more info around this object <a href=\"https://w3c.github.io/webauthn/#dom-authenticatorassertionresponse-userhandle\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">refer to spec</a>.</p>\n<h3 id=\"validating-authentication-data\" style=\"position:relative;\"><a href=\"#validating-authentication-data\" aria-label=\"validating authentication data permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Validating authentication data</h3>\n<p>After the assertion is acquired, it is sent to server for verification. After being validated, the signature is verified with the stored public key.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"95879303277262910000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const storedCredential = await getCredentialFromDatabase(\r\n  userHandle,\r\n  credentialId\r\n)\r\n\r\nconst signedData =\r\n  authenticatorDataBytes + hashedClientDataJSON\r\n\r\nconst signatureIsValid = storedCredential.publicKey.verify(\r\n  signature,\r\n  signedData\r\n)\r\n\r\nif (signatureIsValid) {\r\n  return 'Hooray! User is authenticated! 🎉'\r\n} else {\r\n  return 'Verification failed. 😭'\r\n}`, `95879303277262910000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token keyword\">const</span> storedCredential <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> <span class=\"token function\">getCredentialFromDatabase</span><span class=\"token punctuation\">(</span>\r\n  userHandle<span class=\"token punctuation\">,</span>\r\n  credentialId\r\n<span class=\"token punctuation\">)</span>\r\n\r\n<span class=\"token keyword\">const</span> signedData <span class=\"token operator\">=</span>\r\n  authenticatorDataBytes <span class=\"token operator\">+</span> hashedClientDataJSON\r\n\r\n<span class=\"token keyword\">const</span> signatureIsValid <span class=\"token operator\">=</span> storedCredential<span class=\"token punctuation\">.</span>publicKey<span class=\"token punctuation\">.</span><span class=\"token function\">verify</span><span class=\"token punctuation\">(</span>\r\n  signature<span class=\"token punctuation\">,</span>\r\n  signedData\r\n<span class=\"token punctuation\">)</span>\r\n\r\n<span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>signatureIsValid<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">return</span> <span class=\"token string\">'Hooray! User is authenticated! 🎉'</span>\r\n<span class=\"token punctuation\">}</span> <span class=\"token keyword\">else</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">return</span> <span class=\"token string\">'Verification failed. 😭'</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h1 id=\"further-reading-and-resources\" style=\"position:relative;\"><a href=\"#further-reading-and-resources\" aria-label=\"further reading and resources permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Further reading and resources</h1>\n<p>Following resources are a good starting point for any further reading:</p>\n<ul>\n<li><a href=\"https://webauthn.io\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Webauthn.io</a>: Due Labs has created this useful resource which contains all the source code and sample use cases with beautiful illustrations.</li>\n<li><a href=\"https://duo.com/blog/developments-to-webauthn-and-the-fido2-framework\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Developments to WebAuthn and the FIDO2 Framework</a>: An informative blog post which goes through some of the progress and shows the compatibility of each major browser and contributors to this area.</li>\n<li><a href=\"https://github.com/duo-labs/webauthn.io\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Source Code</a>: This GitHub repo contains all the source code Due Labs have created to demonstrate the capability.</li>\n<li>A Big Day for the Internet: <a href=\"https://www.yubico.com/2019/03/w3c-standardizes-webauthn/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">W3C Standardizes WebAuthn</a></li>\n<li><a href=\"https://demo.yubico.com/webauthn\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Demo site by Yubico</a>: Demonstrates the process in the end user perspective</li>\n</ul>\n<h1 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h1>\n<p>We saw how simple and straight forward is to implement this amazing feature and I highly recommend if you’re working on a green field project definitely consider having this implemented and give users ability to live passwordless 🔥👊🏻. For the current products, this can be a turning point to gain more users into system by simplifying the most important part of their flow 😊.</p>","timeToRead":5,"frontmatter":{"title":"A world without passwords","unformattedDate":"2019-06-05T00:00:00.000Z","date":"Jun 05, 2019","path":"/webauthn/","author":"Yaser Adel Mehraban","tags":["webdev","webauthn","frontend","showdev"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAIBAwQF/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAW2zdZyxQ//EABwQAAICAgMAAAAAAAAAAAAAAAIDAAEEERIUMf/aAAgBAQABBQJeKV2SV2HQ3Ft5s8jco1N//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAHhAAAQQBBQAAAAAAAAAAAAAAAQACERIQITEzYaH/2gAIAQEABj8CFtAq7Ll8T2xFcOaII7X/xAAbEAADAQEAAwAAAAAAAAAAAAAAAREhMUFRYf/aAAgBAQABPyFhIq6rpizS2pl6bfB4Rnb00Lyoq9D/2gAMAwEAAgADAAAAEKgv/8QAFREBAQAAAAAAAAAAAAAAAAAAEBH/2gAIAQMBAT8Qh//EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAECAQE/EKf/xAAcEAEAAgMAAwAAAAAAAAAAAAABABEhMUFRcYH/2gAIAQEAAT8QOrhZZHzUxb1dlHXYoshz4TnY5uBd1lTVY1GkSnuSB+mIVCDXq7n/2Q=="},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/a5f40103ea42e2db324e4000350cc118/d7bd6/webauthn.jpg","srcSet":"/static/a5f40103ea42e2db324e4000350cc118/a83d8/webauthn.jpg 750w,\n/static/a5f40103ea42e2db324e4000350cc118/d7bd6/webauthn.jpg 1000w","sizes":"(min-width: 1000px) 1000px, 100vw"},"sources":[{"srcSet":"/static/a5f40103ea42e2db324e4000350cc118/80567/webauthn.webp 750w,\n/static/a5f40103ea42e2db324e4000350cc118/e18f2/webauthn.webp 1000w","type":"image/webp","sizes":"(min-width: 1000px) 1000px, 100vw"}]},"width":1000,"height":667}}}}}},{"node":{"id":"3044cabc-d627-5af0-8307-1cb11553053a","html":"<p>You might already know that <a href=\"https://angular.io\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Angular</a> 8 is out now, but what it means for you or your organisation is described below.</p>\n<!--more-->\n<h1 id=\"ivy\" style=\"position:relative;\"><a href=\"#ivy\" aria-label=\"ivy permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Ivy</h1>\n<p>To put your mind at rest, Ivy is not here <strong>yet</strong>. If you don’t know what is Ivy, it’s the Angular’s new renderer which promises a ton of improvements in term of how Angular renders the view. It is radically different from anything we have seen in mainstream frameworks, because it uses incremental <code class=\"language-text\">DOM</code>. Stay tuned for more news on this in coming weeks.</p>\n<h1 id=\"differential-loading\" style=\"position:relative;\"><a href=\"#differential-loading\" aria-label=\"differential loading permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Differential loading</h1>\n<p>Differential loading is a feature in which browser decides to use modern vs legacy JavaScript based on its own capabilities.</p>\n<p>This is really important not just because we can use modern JavaScript but because we can get rid of all of those polyfills we’ve had to ship with our applications previously.</p>\n<p>In short it takes advantage of the <code class=\"language-text\">es2015</code> flag in the TypeScript config and creates two bundles one for modern browsers and one for older ones.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"87702344470426570000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`{\r\n  &quot;compilerOptions&quot;: {\r\n  …\r\n  &quot;module&quot;: &quot;esnext&quot;,\r\n  &quot;moduleResolution&quot;: &quot;node&quot;,\r\n  …\r\n  &quot;target&quot;: &quot;es2015&quot;,\r\n  …\r\n},`, `87702344470426570000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-json line-numbers\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">\"compilerOptions\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n  …\r\n  <span class=\"token property\">\"module\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"esnext\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"moduleResolution\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"node\"</span><span class=\"token punctuation\">,</span>\r\n  …\r\n  <span class=\"token property\">\"target\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"es2015\"</span><span class=\"token punctuation\">,</span>\r\n  …\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>At runtime, Angular generates two script tags in your HTML:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"97518697472714440000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<script type=&quot;module&quot; src=&quot;…&quot;> // Modern JS\r\n\r\n<script nomodule src=&quot;…&quot;> // Legacy JS`, `97518697472714440000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>script</span> <span class=\"token attr-name\">type</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>module<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>…<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span> // Modern JS\r\n\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>script</span> <span class=\"token attr-name\">nomodule</span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>…<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span> // Legacy JS</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p>Browsers that can handle modern JavaScript will load the first bundle and ignores the second whereas the older ones ignore the first and load the first one.</p>\n<p>This will give you some massive reduction in bundle size when the application is more than a hello world 😉.</p>\n<h1 id=\"dynamic-imports-in-route-configurations\" style=\"position:relative;\"><a href=\"#dynamic-imports-in-route-configurations\" aria-label=\"dynamic imports in route configurations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Dynamic imports in route configurations</h1>\n<p>Angular team have now changed the way you used to lazy load child modules in route configuration. Previously you had:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"87256750755813340000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`{path: '/about', loadChildren: './about/about.module#AboutModule'}`, `87256750755813340000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token punctuation\">{</span>path<span class=\"token operator\">:</span> <span class=\"token string\">'/about'</span><span class=\"token punctuation\">,</span> loadChildren<span class=\"token operator\">:</span> <span class=\"token string\">'./about/about.module#AboutModule'</span><span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>With the new syntax, it leverages the dynamic import which is a huge advantage over the old syntax:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"64727550906267580000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`{path: \\`/about\\`, loadChildren: () => import(\\`./about/about.module\\`).then(m => m.AboutModule)}`, `64727550906267580000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token punctuation\">{</span>path<span class=\"token operator\">:</span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">/about</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">,</span> <span class=\"token function-variable function\">loadChildren</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token keyword\">import</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">./about/about.module</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span>m <span class=\"token operator\">=></span> m<span class=\"token punctuation\">.</span>AboutModule<span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Why is this better I hear you ask. The main reason is that you can get errors during development from your editor. If you misspelled the module name or the file name previously, it wouldn’t throw error until you trued to bundle the app because it was just a string.</p>\n<p>Now you get squiggly lines under file name or module name if you make a mistake.</p>\n<h1 id=\"builders\" style=\"position:relative;\"><a href=\"#builders\" aria-label=\"builders permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Builders</h1>\n<p>You might know that you can tap into CLI commands like <code class=\"language-text\">ng new</code>, <code class=\"language-text\">ng generate</code>, <code class=\"language-text\">ng add</code>, and <code class=\"language-text\">ng update</code> using Schematics. Angular team now allow you to tap into more commands using the new builders for CLI like <code class=\"language-text\">ng build</code>, <code class=\"language-text\">ng test, and</code>ng run`.</p>\n<p>What this allowed the team to achieve is huge because now you can run your custom build or test flows. One of the good examples is the new version of <a href=\"https://github.com/angular/angularfire2\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">AngularFire</a> which adds a <code class=\"language-text\">deploy</code> command to make the build and deploy seamless when working on a project which uses Firebase for deployment. As if, you can now run:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"76742395695797450000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`ng run hellow-world:deploy`, `76742395695797450000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\">ng run hellow-world:deploy</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>This command will both build the project and deploys it to Firebase, how good is this?</p>\n<h1 id=\"workspace-apis\" style=\"position:relative;\"><a href=\"#workspace-apis\" aria-label=\"workspace apis permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Workspace APIs</h1>\n<p>Up until now, you had to manually open your <code class=\"language-text\">angular.json</code> and modify it to make changes to workspace config. With this new API you can now read and modify these configurations much more conveniently. <a href=\"https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/core/README.md#workspaces\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Read more here</a>.</p>\n<h1 id=\"web-worker-support\" style=\"position:relative;\"><a href=\"#web-worker-support\" aria-label=\"web worker support permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Web Worker Support</h1>\n<p>Web workers are great for adding support to offload a heavy operation in a different thread and speed up your application’s performance. Imagine image or video manipulation, or finding the optimum path between two points on a map and how they can impact the application’s speed.</p>\n<p>Now you can add a web worker easily by running:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"62550422637837610000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`ng generate webWorker awesome-worker`, `62550422637837610000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\">ng generate webWorker awesome-worker</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Once finished you will have a web worker and you can use it in your application. The CLI will take care of the bundling for you, so all you need to do, is leverage the power it brings to you:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"93933970675480660000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const worker = new Worker(\r\n  \\`./awesome-worker.worker\\`,\r\n  { type: \\`module\\` }\r\n)`, `93933970675480660000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token keyword\">const</span> worker <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Worker</span><span class=\"token punctuation\">(</span>\r\n  <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">./awesome-worker.worker</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">{</span> type<span class=\"token operator\">:</span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">module</span><span class=\"token template-punctuation string\">`</span></span> <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">)</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>To make this even more interesting, CLI will also correctly handle the code splitting and bundling.</p>\n<p>In your worker file which is located in <code class=\"language-text\">src/app/awesome.worker.ts</code>, you will have a scaffolded method to receive a message from your application as a starter which you can expand however you like:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"3974942604820364000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`addEventListener('message', ({ data }) => {\r\n  const response = \\`worker response to \\${data}\\`\r\n  postMessage(response)\r\n})`, `3974942604820364000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token function\">addEventListener</span><span class=\"token punctuation\">(</span><span class=\"token string\">'message'</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span> data <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">const</span> response <span class=\"token operator\">=</span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">worker response to </span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>data<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span>\r\n  <span class=\"token function\">postMessage</span><span class=\"token punctuation\">(</span>response<span class=\"token punctuation\">)</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>In your <code class=\"language-text\">app.component.ts</code> you can then interact with the worker and send a message:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"62162964300471280000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`if (typeof Worker !== 'undefined') {\r\n  // Create a new\r\n  const worker = new Worker('./awesome.worker', {\r\n    type: 'module',\r\n  })\r\n  worker.onmessage = ({ data }) => {\r\n    console.log('page got message: \\${data}')\r\n  }\r\n  worker.postMessage('hello')\r\n} else {\r\n  // Web Workers are not supported in this environment.\r\n  // You should add a fallback so that your program still executes correctly.\r\n}`, `62162964300471280000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"ts\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-ts line-numbers\"><code class=\"language-ts\"><span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span><span class=\"token keyword\">typeof</span> Worker <span class=\"token operator\">!==</span> <span class=\"token string\">'undefined'</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token comment\">// Create a new</span>\r\n  <span class=\"token class-name\"><span class=\"token keyword\">const</span></span> worker <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Worker</span><span class=\"token punctuation\">(</span><span class=\"token string\">'./awesome.worker'</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span>\r\n    type<span class=\"token operator\">:</span> <span class=\"token string\">'module'</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\r\n  worker<span class=\"token punctuation\">.</span><span class=\"token function-variable function\">onmessage</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span> data <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token builtin\">console</span><span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token string\">'page got message: ${data}'</span><span class=\"token punctuation\">)</span>\r\n  <span class=\"token punctuation\">}</span>\r\n  worker<span class=\"token punctuation\">.</span><span class=\"token function\">postMessage</span><span class=\"token punctuation\">(</span><span class=\"token string\">'hello'</span><span class=\"token punctuation\">)</span>\r\n<span class=\"token punctuation\">}</span> <span class=\"token keyword\">else</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token comment\">// Web Workers are not supported in this environment.</span>\r\n  <span class=\"token comment\">// You should add a fallback so that your program still executes correctly.</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h1 id=\"angularjs-migration\" style=\"position:relative;\"><a href=\"#angularjs-migration\" aria-label=\"angularjs migration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>AngularJS migration</h1>\n<p>If you were using <code class=\"language-text\">$location</code> service in your AngularJS application, now you will get <code class=\"language-text\">LocationUpgradeModule</code> which puts the responsibilities of <code class=\"language-text\">$location</code> service to <code class=\"language-text\">Location</code> service in Angular.</p>\n<p>This means if you’re use <code class=\"language-text\">ngUpgrade</code>, your life is a bit easier having routes in both AngularJS and Angular apps.</p>\n<p>Documentation around best practices for lazy loading parts of AngularJS app into your Angular app is also happened in this version which gives you insight on how to upgrade most used features first, and only load AngularJS for the remaining subset.</p>\n<p>Read more around the <a href=\"https://v8.angular.io/guide/upgrade#create-a-service-to-lazy-load-angularjs\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">best practices here</a>.</p>\n<h1 id=\"new-guide-around-deprecated-features\" style=\"position:relative;\"><a href=\"#new-guide-around-deprecated-features\" aria-label=\"new guide around deprecated features permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>New guide around deprecated features</h1>\n<p>They also release a new guide around deprecations and removals. They claimed they are committed to support features in <code class=\"language-text\">N + 2</code> in major releases. For example if you’re using a deprecated feature in Angular 7, it will be available in 8 and 9, but not 10.</p>\n<p>One of the features which is now deprecated in 8 is <code class=\"language-text\">platform-webworker</code>. To find out about all deprecated and removals check out <a href=\"https://v8.angular.io/guide/deprecations\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">their deprecation guide</a>.</p>\n<h1 id=\"breaking-changes\" style=\"position:relative;\"><a href=\"#breaking-changes\" aria-label=\"breaking changes permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Breaking changes</h1>\n<p>This version came with some breaking changes. The most important one is that <code class=\"language-text\">@bazel/typescript</code> is now a <code class=\"language-text\">peerDependency</code> of <code class=\"language-text\">@angular/bazel</code> so its users must add <code class=\"language-text\">@bazel/typescript</code> to their <code class=\"language-text\">package.json</code>.</p>\n<p>From core perspective, it’s now required that all <code class=\"language-text\">@ViewChild</code> and <code class=\"language-text\">@ContentChild</code> queries have a <em>static</em> flag specifying whether the query is <em>static</em> or <em>dynamic</em>. The compiler previously sorted queries automatically, but in 8.0 developers are required to explicitly specify which behaviour they have in mind. This is a temporary requirement as part of a migration; see <a href=\"https://v8.angular.io/guide/static-query-migration\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https://v8.angular.io/guide/static-query-migration</a> for more details.</p>\n<p>To read more refer to <a href=\"https://github.com/angular/angular/blob/master/CHANGELOG.md\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">their change log</a>.</p>\n<h1 id=\"how-to-update\" style=\"position:relative;\"><a href=\"#how-to-update\" aria-label=\"how to update permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>How to update</h1>\n<p>Simply run this command from your terminal and have fun exploring these new hot features.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"94766645486393520000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`ng update @angular/cli @angular/core`, `94766645486393520000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\">ng update @angular/cli @angular/core</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>The rest is taken care of by the CLI.</p>","timeToRead":4,"frontmatter":{"title":"What`s new in Angular 8","unformattedDate":"2019-05-30T00:00:00.000Z","date":"May 30, 2019","path":"/angular-8-features/","author":"Yaser Adel Mehraban","tags":["angular","webdev","showdev","features"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAUABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAQCBf/EABUBAQEAAAAAAAAAAAAAAAAAAAEA/9oADAMBAAIQAxAAAAHuSalLrBszi1AP/8QAGhAAAwEBAQEAAAAAAAAAAAAAAQIDAAQRI//aAAgBAQABBQJvQoZhXdTFZn5VzKGCc85tv//EABcRAAMBAAAAAAAAAAAAAAAAABESIEH/2gAIAQMBAT8BYZH/xAAXEQEAAwAAAAAAAAAAAAAAAAARARIg/9oACAECAQE/AayuP//EABsQAAICAwEAAAAAAAAAAAAAAAECABIQESFB/9oACAEBAAY/AuRRawbHPTEo1i2NMNiWA7j/xAAdEAACAgIDAQAAAAAAAAAAAAABEQAhEDFBUWGB/9oACAEBAAE/ITIO0pfl+YH3VBPUUloRFXg3cOJ9oxOsf//aAAwDAQACAAMAAAAQ18c8/8QAGhEAAgIDAAAAAAAAAAAAAAAAARARITHB8P/aAAgBAwEBPxARxbtIYX//xAAYEQEAAwEAAAAAAAAAAAAAAAABEBEhUf/aAAgBAgEBPxC4WzkChH//xAAdEAEAAQQDAQAAAAAAAAAAAAABEQAQIUExUWGB/9oACAEBAAE/EIzes69ouF5MHEwkWVkiF0rH4ekKS47sLTkKpynWV8W//9k="},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/f5dab050d5f4640b176c749d9ac470d5/e4cbc/8.jpg","srcSet":"/static/f5dab050d5f4640b176c749d9ac470d5/e4d02/8.jpg 750w,\n/static/f5dab050d5f4640b176c749d9ac470d5/e4cbc/8.jpg 900w","sizes":"(min-width: 900px) 900px, 100vw"},"sources":[{"srcSet":"/static/f5dab050d5f4640b176c749d9ac470d5/cd166/8.webp 750w,\n/static/f5dab050d5f4640b176c749d9ac470d5/eec97/8.webp 900w","type":"image/webp","sizes":"(min-width: 900px) 900px, 100vw"}]},"width":900,"height":900}}}}}}]}},"pageContext":{"limit":10,"skip":60,"numPages":13,"currentPage":7}},"staticQueryHashes":[],"slicesMap":{}}