{"componentChunkName":"component---src-templates-blog-list-js","path":"/blog/3/","result":{"data":{"allMarkdownRemark":{"edges":[{"node":{"id":"e2cfbc70-88fb-55db-8c76-c9223b28dbcd","html":"<p>If you’re a windows user like me, you might have heard of PowerToys Utilities from Microsoft. They are a set of utilities which come handy in many situations, but not many people know and use them. So I thought let’s write how and when I use them to help other people be more efficient too.</p>\n<!--more-->\n<h2 id=\"powertoys-utilities\" style=\"position:relative;\"><a href=\"#powertoys-utilities\" aria-label=\"powertoys utilities 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>PowerToys utilities</h2>\n<p><a href=\"https://github.com/microsoft/PowerToys\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Microsoft PowerToys</a> are a set of small applications which helps windows users streamline their day to day activities and windows experience for greater productivity. However, these are not new. There were a set of tools in <a href=\"https://en.wikipedia.org/wiki/Microsoft_PowerToys\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Widows 95</a> (yes I’m that old) which inspired this project.</p>\n<h3 id=\"installation\" style=\"position:relative;\"><a href=\"#installation\" aria-label=\"installation 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>Installation</h3>\n<p>Simply head to the <a href=\"https://github.com/microsoft/PowerToys/releases/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Downloading and Release notes</a> section on their GitHub repository, download the version you’re after and install it using its installer.</p>\n<p>The latest version as of writing this article is <a href=\"https://github.com/microsoft/PowerToys/releases/download/v0.23.0/PowerToysSetup-0.23.0-x64.exe\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">v0.23.0</a>. Once you get it installed, it will update itself on a regular basis.</p>\n<p>So let’s see what are these and how you can use them.</p>\n<h3 id=\"color-picker\" style=\"position:relative;\"><a href=\"#color-picker\" aria-label=\"color picker 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>Color picker</h3>\n<p><a href=\"https://aka.ms/PowerToysOverview_ColorPicker\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Color Picker</a> is a handy little tool which allows you to pick a color from anywhere on your screen. As a web developer there are many times when I want to get the hex or rgb value of a background color, border, or other areas.</p>\n<p>I used to use browser DevTools, but they only help you within the browser and if you want something from a document, picture or other files on your file system, then this tool will come in handy.</p>\n<p>If you haven’t customised the default shortcuts, press <kbd>Win</kbd> + <kbd>Shift</kbd> + <kbd>C</kbd> to open the picker. Once opened, you can use your mouse scroll to zoom in and left click to copy the value to your clipboard.</p>\n<p><img src=\"/b718c42b2982d179f52fd2a406561e5e/colorpicker.gif\" alt=\"PowerToys color picker\"></p>\n<h3 id=\"fancy-zones\" style=\"position:relative;\"><a href=\"#fancy-zones\" aria-label=\"fancy zones 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>Fancy zones</h3>\n<p><a href=\"https://aka.ms/PowerToysOverview_FancyZones\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Fancy Zones</a> allows you to create complex window layouts and quickly position your windows into those. This comes really handy if you have a super wide monitor setup.</p>\n<p>To open it, press <kbd>Win</kbd> + <kbd>`</kbd> and select your desired layout from the opened window. Once selected you can arrange your windows into those areas by pressing <kbd>Win</kbd> + <kbd>⬅</kbd> or <kbd>Win</kbd> + <kbd>➡</kbd>.</p>\n<img src=\"/6aaf1ac433744a0b72f020a3661163f0/fancyzones.gif\" alt=\"Fancy Zones from windows PowerToys\" loading=\"lazy\">\n<blockquote>\n<p>💡 If the arrow keys didn’t work for you, simply select the option to override windows shortcuts in the settings. You can access the settings from clicking the PowerToys icon in your toolbar.</p>\n</blockquote>\n<h3 id=\"file-explorer-add-ons\" style=\"position:relative;\"><a href=\"#file-explorer-add-ons\" aria-label=\"file explorer add ons 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>File explorer add-ons</h3>\n<p><a href=\"https://aka.ms/PowerToysOverview_FileExplorerAddOns\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">File Explorer add-ons</a> will enable SVG icon rendering and markdown preview for your file explorer. To see your preview pane simply click the view menu and click the preview pane.</p>\n<img src=\"/5df9c43c0ceda88fd1da28bc6819816d/fileexploreraddons.gif\" alt=\"Fancy Zones from windows PowerToys\" loading=\"lazy\">\n<h3 id=\"image-resizer\" style=\"position:relative;\"><a href=\"#image-resizer\" aria-label=\"image resizer 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>Image resizer</h3>\n<p><a href=\"https://aka.ms/PowerToysOverview_ImageResizer\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Image Resizer</a> is a really cool shell extension which allows you to quickly resize images. Simply right click on your image or images and resize them instantly.</p>\n<img src=\"/296d47745d0282bf1af22655d3f208ac/imageresizer.gif\" alt=\"Fancy Zones from windows PowerToys\" loading=\"lazy\">\n<h3 id=\"keyboard-manager\" style=\"position:relative;\"><a href=\"#keyboard-manager\" aria-label=\"keyboard manager 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>keyboard manager</h3>\n<p>Keyboard manager allows you to create your own keyboard layout to increase your productivity. You can map keys and mix them however you like, of course you would need a keyboard with detachable key caps for a better use.</p>\n<p>Open PowerToys settings and click on keyboard manager menu. First thing first, make sure it’s enabled.</p>\n<p><strong>Remap keys</strong></p>\n<p>If you want to remap a key, click on the remap keys, then click <kbd>+</kbd> button to add a key and then select what key you want that mapped to.</p>\n<img src=\"/11bff19abe860f5004a998896c049814/remapkeys.gif\" alt=\"Keyboard manager remap key\" loading=\"lazy\">\n<p>You can also map a single key to a shortcut, for example map <kbd>V</kbd> to <kbd>Ctrl</kbd> + <kbd>V</kbd>.</p>\n<blockquote>\n<p>💡 Just remember that when you map a key to a shortcut, the combination remains even as part of other key presses. So if you’ve mapped <kbd>V</kbd> as above, then pressing <kbd>Ctrl</kbd> + <kbd>V</kbd> now means you’ve pressed <kbd>Ctrl</kbd> + <kbd>V</kbd> + <kbd>V</kbd>.</p>\n</blockquote>\n<p><strong>Remap shortcuts</strong></p>\n<p>You can map shortcuts as well, to do so, click on the <em>remap a shortcut</em> button and follow the same procedure. You can click on type button to press multiple keys and at the end you can specify which application this shortcut remap applies to.</p>\n<img src=\"/4f1086cf89d03789fab0486b896b590e/shortcutremap.gif\" alt=\"Keyboard manager remap key\" loading=\"lazy\">\n<h3 id=\"powerrename\" style=\"position:relative;\"><a href=\"#powerrename\" aria-label=\"powerrename 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>PowerRename</h3>\n<p><a href=\"https://aka.ms/PowerToysOverview_PowerRename\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">PowerRename</a> is another shell extension for balk renaming of files which offers search and replace and supports regex.</p>\n<p>Select and right click on multiple files or folders, then click <strong>PowerRename</strong>. From the opened dialog, select your desired options and once you’re happy, click rename.</p>\n<img src=\"/63b31fade1bf4db30915571eac64025d/renamer.gif\" alt=\"Keyboard manager remap key\" loading=\"lazy\">\n<h3 id=\"powertoys-run\" style=\"position:relative;\"><a href=\"#powertoys-run\" aria-label=\"powertoys run 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>PowerToys run</h3>\n<p>This one is my favourite. It brings back the memories of the days we used to install add-ons on windows XP and 7 to add these sort of functionalities. First, make sure it’s enabled in the settings, and then press <kbd>Alt</kbd> + <kbd>Space</kbd>. A pop up will open and you can search for your application.</p>\n<blockquote>\n<p>💡 Since I use this shortcut to select my open window to be able to move it between my monitors, I’ve set my shortcut to <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Space</kbd>.</p>\n</blockquote>\n<h3 id=\"shortcut-guide\" style=\"position:relative;\"><a href=\"#shortcut-guide\" aria-label=\"shortcut guide 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>Shortcut guide</h3>\n<p><a href=\"https://aka.ms/PowerToysOverview_ShortcutGuide\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Shortcut guide</a> is a quick and easy way to savailable shortcuts for the current state of the desktop. You can open it by pressing and holding down your <kbd>Win</kbd> key for 1 second.</p>\n<img src=\"/671f38fe4b784f855731785a559aeeac/shortcutguide.gif\" alt=\"Keyboard manager remap key\" loading=\"lazy\">\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>Hopefully these tools will help you as much as they helped me. Have a great weekend ahead and till next article 👋🏻.</p>","timeToRead":3,"frontmatter":{"title":"Do you know about PowerToy Utilities? 💪🏻","unformattedDate":"2020-10-09T00:00:00.000Z","date":"Oct 09, 2020","path":"/powertoys/","author":"Yaser Adel Mehraban","tags":["showdev","windows","powertoys"],"thumbnail":null}}},{"node":{"id":"db113d4f-1e9c-531c-82cd-4571a56e8a9a","html":"<p>Searching for items in an array has been the point of discussion for many years and debate on what is the best and optimum way for searching for objects has had many solutions, some effective and some not.</p>\n<p>However, with the all new <code class=\"language-text\">findIndex</code> method on <code class=\"language-text\">Array.prototype</code> you have the flexibility to search for objects using your own comparison callback method.</p>\n<!--more-->\n<h2 id=\"the-what\" style=\"position:relative;\"><a href=\"#the-what\" aria-label=\"the what 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>The what</h2>\n<p>The <code class=\"language-text\">findIndex</code> method returns the index of the first element in an array if the callback method passed to it returns <code class=\"language-text\">true</code>, otherwise it returns <code class=\"language-text\">-1</code>.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"1946705612305521400\"\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 isPerfectSquare = (num) => {\r\n  return num > 0 && Math.sqrt(num) % 1 === 0;\r\n}\r\n\r\nconsole.log([1, 3, 8, 9, 12].findIndex(isPerfectSquare)); // 1\r\nconsole.log([1, 6, 7, 10, 14].findIndex(isPerfectSquare)); // -1`, `1946705612305521400`)\"\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\">isPerfectSquare</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">num</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">return</span> num <span class=\"token operator\">></span> <span class=\"token number\">0</span> <span class=\"token operator\">&amp;&amp;</span> Math<span class=\"token punctuation\">.</span><span class=\"token function\">sqrt</span><span class=\"token punctuation\">(</span>num<span class=\"token punctuation\">)</span> <span class=\"token operator\">%</span> <span class=\"token number\">1</span> <span class=\"token operator\">===</span> <span class=\"token number\">0</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><span class=\"token punctuation\">[</span><span class=\"token number\">1</span><span class=\"token punctuation\">,</span> <span class=\"token number\">3</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 number\">12</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span><span class=\"token function\">findIndex</span><span class=\"token punctuation\">(</span>isPerfectSquare<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// 1</span>\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span><span class=\"token number\">1</span><span class=\"token punctuation\">,</span> <span class=\"token number\">6</span><span class=\"token punctuation\">,</span> <span class=\"token number\">7</span><span class=\"token punctuation\">,</span> <span class=\"token number\">10</span><span class=\"token punctuation\">,</span> <span class=\"token number\">14</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span><span class=\"token function\">findIndex</span><span class=\"token punctuation\">(</span>isPerfectSquare<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// -1</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>There are two facts you should know:</p>\n<ul>\n<li>This method does not run once it found the first matching element.</li>\n<li>It does not change the original array.</li>\n</ul>\n<h2 id=\"syntax\" style=\"position:relative;\"><a href=\"#syntax\" aria-label=\"syntax 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>Syntax</h2>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"58395277432053690000\"\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.findIndex(function(currentValue, index, arr), thisValue);`, `58395277432053690000`)\"\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\">array<span class=\"token punctuation\">.</span><span class=\"token function\">findIndex</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">function</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">currentValue<span class=\"token punctuation\">,</span> index<span class=\"token punctuation\">,</span> arr</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span> thisValue<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<h3 id=\"parameters\" style=\"position:relative;\"><a href=\"#parameters\" aria-label=\"parameters 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>Parameters</h3>\n<ul>\n<li><strong>function:</strong> This is your callback function which checks for a condition to match the element you’re after.</li>\n<li><strong>currentValue:</strong> This holds the current element’s value.</li>\n<li><strong>index:</strong> This is an optional parameter which holds the current index.</li>\n<li><strong>arr:</strong> This is also an optional parameter which holds the array that the current element belongs to.</li>\n<li><strong>thisValue:</strong> Yet another optional parameter, if a value is passed, it will be used as <code class=\"language-text\">this</code> value inside the function, otherwise <code class=\"language-text\">undefined</code> will be passed.</li>\n</ul>\n<h3 id=\"return-value\" style=\"position:relative;\"><a href=\"#return-value\" aria-label=\"return value 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>Return value</h3>\n<p>It will return the index of the found item or <code class=\"language-text\">-1</code> if the callback function is not satisfied.</p>\n<h2 id=\"how-it-works-under-the-hood\" style=\"position:relative;\"><a href=\"#how-it-works-under-the-hood\" aria-label=\"how it works under the hood 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 under the hood?</h2>\n<p>When the <code class=\"language-text\">findIndex</code> is called with one or two arguments, the following steps are executed:</p>\n<ol>\n<li>Let <code class=\"language-text\">O</code> be ? <code class=\"language-text\">ToObject(this value)</code></li>\n<li>Let <code class=\"language-text\">len</code> be ? <code class=\"language-text\">LengthOfArrayLike(O)</code></li>\n<li>If <code class=\"language-text\">IsCallback(predicate)</code> is <code class=\"language-text\">false</code>, throw a <strong>TypeError</strong> exception</li>\n<li>Let <code class=\"language-text\">k</code> be 0</li>\n<li>Repeat, while <code class=\"language-text\">k &lt; len</code></li>\n</ol>\n<ul>\n<li>Let <code class=\"language-text\">Pk</code> be ! <code class=\"language-text\">ToString(k)</code></li>\n<li>Let <code class=\"language-text\">kValue</code> be ? <code class=\"language-text\">Get(O, Pk)</code></li>\n<li>Let <code class=\"language-text\">testResult</code> be ! <code class=\"language-text\">ToBoolean(? Call(predicate, thisArg, « kValue, k, O »))</code></li>\n<li>If <code class=\"language-text\">testResult</code> is <code class=\"language-text\">true</code>, return <code class=\"language-text\">k</code></li>\n<li>Set <code class=\"language-text\">k</code> to <code class=\"language-text\">k + 1</code></li>\n</ul>\n<ol start=\"6\">\n<li>Return <code class=\"language-text\">-1</code></li>\n</ol>","timeToRead":1,"frontmatter":{"title":"Find an item in an array with the new 'findIndex' method 🔎","unformattedDate":"2020-10-05T00:00:00.000Z","date":"Oct 05, 2020","path":"/array-findindex/","author":"Yaser Adel Mehraban","tags":["showdev","webdev","javascript","findindex"],"thumbnail":null}}},{"node":{"id":"311de7ae-f9be-5da6-b42d-e979c22a3b3e","html":"<p>It’s been a while since I last wrote about Intersection Observer V2, partly because I had a lot on my plate and I was feeling exhausted and partly because I was working on my first <a href=\"app.pluralsight.com/library/courses/web-performance-progressive-web-apps\">PluralSight course on web performance for PWAs</a>.</p>\n<p>But I am back, and this time we’re going to review how to take a selfie from your webcam using <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/MediaStream_Image_Capture_API\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Image Capture API</a>.</p>\n<!--more-->\n<h2 id=\"image-capture-api\" style=\"position:relative;\"><a href=\"#image-capture-api\" aria-label=\"image capture api 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>Image Capture API</h2>\n<p>There are some really useful APIs which allow us to work with media like audio, video, etc. I will write about those too, but this time I wanted to show you how you can extract a frame from your video feed such as your webcam with a few lines of code.</p>\n<p><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/MediaStream_Image_Capture_API\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Image Capture API</a> enables us to capture an image or frame from video devices. In addition to capturing data, it also allows you to retrieve information about device capability such as image size, red-eye detection and whether or not there is flash turned on.</p>\n<h2 id=\"usage\" style=\"position:relative;\"><a href=\"#usage\" aria-label=\"usage 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>Usage</h2>\n<p>We need to take some actions to be able to work with media devices. First thing first we need to get a reference of the device:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"51721049651523070000\"\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(`navigator.mediaDevices.getUserMedia({ video: true })\r\n  .then(mediaStream => {\r\n    // Do something with the stream.\r\n  })`, `51721049651523070000`)\"\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\">navigator<span class=\"token punctuation\">.</span>mediaDevices<span class=\"token punctuation\">.</span><span class=\"token function\">getUserMedia</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">video</span><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 punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">mediaStream</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token comment\">// Do something with the stream.</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>Next we need to get the visual parts of the media stream by calling <code class=\"language-text\">getVideoTracks</code> method of the <code class=\"language-text\">mediaStream</code> object:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"49396930122330866000\"\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 track = mediaStream.getVideoTracks()[0];`, `49396930122330866000`)\"\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> track <span class=\"token operator\">=</span> mediaStream<span class=\"token punctuation\">.</span><span class=\"token function\">getVideoTracks</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">[</span><span class=\"token number\">0</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>Of course we’re assuming that the first item in the array is the one you want to use, but don’t worry if not, you can loop through all the tracks, find the one you need and either get it with its right index, or by calling <code class=\"language-text\">getTrackById</code> method.</p>\n<p>After we’ve got our track, it’s time to capture our image. If you wanted to configure some of the settings on your media device such as zoom level, you need to do it now before capturing our image:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"27999469532900844000\"\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 capabilities = track.getCapabilities();\r\n// Check whether zoom is supported or not.\r\nif(!capabilities.zoom) {\r\n  return;\r\n}\r\n\r\nconst zoom = capabilities.zoom.max - capabilities.zoom.min;\r\n\r\ntrack.applyConstraints({ advanced : [{ zoom: zoom }] });`, `27999469532900844000`)\"\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> capabilities <span class=\"token operator\">=</span> track<span class=\"token punctuation\">.</span><span class=\"token function\">getCapabilities</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">// Check whether zoom is supported or not.</span>\r\n<span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span><span class=\"token operator\">!</span>capabilities<span class=\"token punctuation\">.</span>zoom<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">return</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span>\r\n\r\n<span class=\"token keyword\">const</span> zoom <span class=\"token operator\">=</span> capabilities<span class=\"token punctuation\">.</span>zoom<span class=\"token punctuation\">.</span>max <span class=\"token operator\">-</span> capabilities<span class=\"token punctuation\">.</span>zoom<span class=\"token punctuation\">.</span>min<span class=\"token punctuation\">;</span>\r\n\r\ntrack<span class=\"token punctuation\">.</span><span class=\"token function\">applyConstraints</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">advanced</span> <span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">zoom</span><span class=\"token operator\">:</span> zoom <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></span><span></span><span></span><span></span></span></pre></div>\n<p>When we’re done with settings, we can then create an instance of the <code class=\"language-text\">ImageCapture</code> object:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"92433939383934320000\"\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 imageCapture = new ImageCapture(track);`, `92433939383934320000`)\"\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> imageCapture <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">ImageCapture</span><span class=\"token punctuation\">(</span>track<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>Once that’s done, you can capture an image from your video feed by calling the <code class=\"language-text\">takePhoto</code> method:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"68179393071911944000\"\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(`imageCapture.takePhoto()\r\n  .then(blob => createImageBitmap(blob))\r\n  .then(imageBitmap => {\r\n    // do something with the photo\r\n  })\r\n  .catch(error => console.error(error));`, `68179393071911944000`)\"\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\">imageCapture<span class=\"token punctuation\">.</span><span class=\"token function\">takePhoto</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 parameter\">blob</span> <span class=\"token operator\">=></span> <span class=\"token function\">createImageBitmap</span><span class=\"token punctuation\">(</span>blob<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 parameter\">imageBitmap</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token comment\">// do something with the photo</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\r\n  <span class=\"token punctuation\">.</span><span class=\"token function\">catch</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">error</span> <span class=\"token operator\">=></span> console<span class=\"token punctuation\">.</span><span class=\"token function\">error</span><span class=\"token punctuation\">(</span>error<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></pre></div>\n<h2 id=\"permissions\" style=\"position:relative;\"><a href=\"#permissions\" aria-label=\"permissions 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>Permissions</h2>\n<p>Similar to other APIs you would need permission to be able to access the webcam on devices. If you didn’t see any pop up, make sure you give the camera permission to the site on your browser to be able to get your code working properly. You can try that with below demo.</p>\n<h2 id=\"demo\" style=\"position:relative;\"><a href=\"#demo\" aria-label=\"demo 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>Demo</h2>\n<p>You can see a working example of this in my CodePen below:</p>\n<iframe height=\"265\" style=\"width: 100%;\" scrolling=\"no\" title=\"Image Capture API\" src=\"https://codepen.io/yashints/embed/preview/bGpaWKY?height=265&theme-id=light&default-tab=result\" frameborder=\"no\" loading=\"lazy\" allowtransparency=\"true\" allowfullscreen=\"true\">\r\n  See the Pen <a href='https://codepen.io/yashints/pen/bGpaWKY'>Image Capture API</a> by Yaser Adel Mehraban\r\n  (<a href='https://codepen.io/yashints'>@yashints</a>) on <a href='https://codepen.io'>CodePen</a>.\r\n</iframe>\n<p>I hope you’ve learnt a new thing or two and till next time 👋🏽.</p>","timeToRead":2,"frontmatter":{"title":"Take a selfie 🤳 using Image Capture API and a few lines of code","unformattedDate":"2020-09-06T00:00:00.000Z","date":"Sep 06, 2020","path":"/image-capture-api/","author":"Yaser Adel Mehraban","tags":["showdev","webdev","javascript","imagecaptureapi"],"thumbnail":null}}},{"node":{"id":"7764a9b0-4602-58ba-98eb-d277a36b4768","html":"<p>As I mentioned in <a href=\"https://yashints.dev/blog/2018/11/12/web-perf-4\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">one of my other posts</a>, <strong>Intersection Observer</strong> will report when an element appears in the viewport, after applying all <code class=\"language-text\">overflow</code> and <code class=\"language-text\">CSS clips</code>. However, there is no way currently to find out whether an item is being put on top of this element, or some filter is applied to it which may alter or obscure the element’s display.</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><a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Intersection Observer</a> is now widely used by developers especially since Safari added support a while back and it’s now available in all major browsers. If you want to be notified when an element appears in the viewport such as an image, if you want to lazy load it you can use this API. In its most basic form the code looks like this:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"21598417141367144000\"\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 logIfIsInViewPort = (entries) => {\r\n  for (const entry of entries) {\r\n    if (entry.isIntersecting) {\r\n      console.log(entry);\r\n    }\r\n  }\r\n};\r\n\r\nconst observer = new IntersectionObserver(logIfIsInViewPort);\r\nobserver.observe(document.querySelector('.element-selector'));`, `21598417141367144000`)\"\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=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\"><span class=\"token keyword\">const</span> <span class=\"token function-variable function\">logIfIsInViewPort</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">entries</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">for</span> <span class=\"token punctuation\">(</span><span class=\"token keyword\">const</span> entry <span class=\"token keyword\">of</span> entries<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>entry<span class=\"token punctuation\">.</span>isIntersecting<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>entry<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<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">const</span> observer <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">IntersectionObserver</span><span class=\"token punctuation\">(</span>logIfIsInViewPort<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\nobserver<span class=\"token punctuation\">.</span><span class=\"token function\">observe</span><span class=\"token punctuation\">(</span>document<span class=\"token punctuation\">.</span><span class=\"token function\">querySelector</span><span class=\"token punctuation\">(</span><span class=\"token string\">'.element-selector'</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></pre></div>\n<h2 id=\"the-problem\" style=\"position:relative;\"><a href=\"#the-problem\" aria-label=\"the problem 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>The problem</h2>\n<p>As great as it sounds, this API is not perfect. For example it can’t tell you whether or not an element is covered by another content (which is called occluded), or if a filter is applied to it to hide or obscure it’s content (such as <code class=\"language-text\">opacity</code>, <code class=\"language-text\">filter</code>, <code class=\"language-text\">transform</code>, etc.).</p>\n<p>This can lead to dangerous situations where some people might do fraud or abuse the web. So <a href=\"https://w3c.github.io/IntersectionObserver/v2/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Intersection Observer V2</a> was born to prevent these types of scenarios.</p>\n<h2 id=\"intersection-observer-v2\" style=\"position:relative;\"><a href=\"#intersection-observer-v2\" aria-label=\"intersection observer v2 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>Intersection Observer V2</h2>\n<p>As I said, the primary motivation for this API is to prevent those situations where a fraud might be possible, or people could abuse the user’s privacy in a way especially if the said content is put in an iframe.</p>\n<p>Intersection Observer V2 works by tracking the actual visibility of the element, just like the end user would see it. By passing an option to it’s constructor, the collection of <code class=\"language-text\">IntersectionObserverEntry</code> will contain a new boolean called <code class=\"language-text\">isVisible</code>.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"56778081925252825000\"\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 handler = (changes) => {\r\n  for(const change in changes) {\r\n    // feature detection\r\n    if(typeof change.isVisible !== 'undefined') {\r\n      if(change.isIntersecting && change.isVisible) {\r\n        console.log(\\`Visible since \\${change.time}\\`);\r\n      } else {\r\n        // fallback to v1 if not supported\r\n        change.isVisible = true;\r\n      }\r\n    }\r\n  }\r\n}\r\n\r\nconst observer = new IntersectionObserver(handler, {\r\n  threshold: [1.0],  \r\n  trackVisibility: true, // this will give you the isVisible property\r\n  delay: 100\r\n});\r\n\r\nobserver.observe(document.querySelector('.target-element-selector'));`, `56778081925252825000`)\"\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\">handler</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">changes</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">for</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">const</span> change <span class=\"token keyword\">in</span> changes<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token comment\">// feature detection</span>\r\n    <span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">typeof</span> change<span class=\"token punctuation\">.</span>isVisible <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 keyword\">if</span><span class=\"token punctuation\">(</span>change<span class=\"token punctuation\">.</span>isIntersecting <span class=\"token operator\">&amp;&amp;</span> change<span class=\"token punctuation\">.</span>isVisible<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><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Visible since </span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>change<span class=\"token punctuation\">.</span>time<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>\r\n      <span class=\"token punctuation\">}</span> <span class=\"token keyword\">else</span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token comment\">// fallback to v1 if not supported</span>\r\n        change<span class=\"token punctuation\">.</span>isVisible <span class=\"token operator\">=</span> <span class=\"token boolean\">true</span><span class=\"token punctuation\">;</span>\r\n      <span class=\"token punctuation\">}</span>\r\n    <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\">const</span> observer <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">IntersectionObserver</span><span class=\"token punctuation\">(</span>handler<span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">threshold</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span><span class=\"token number\">1.0</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>  \r\n  <span class=\"token literal-property property\">trackVisibility</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span><span class=\"token punctuation\">,</span> <span class=\"token comment\">// this will give you the isVisible property</span>\r\n  <span class=\"token literal-property property\">delay</span><span class=\"token operator\">:</span> <span class=\"token number\">100</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\nobserver<span class=\"token punctuation\">.</span><span class=\"token function\">observe</span><span class=\"token punctuation\">(</span>document<span class=\"token punctuation\">.</span><span class=\"token function\">querySelector</span><span class=\"token punctuation\">(</span><span class=\"token string\">'.target-element-selector'</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></span><span></span></span></pre></div>\n<h2 id=\"additional-parameters\" style=\"position:relative;\"><a href=\"#additional-parameters\" aria-label=\"additional parameters 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>Additional parameters</h2>\n<p>The object which is passed in the constructor has a few properties:</p>\n<ul>\n<li><strong>threshold</strong>: A list of thresholds which will trigger a callback.</li>\n<li><strong>trackVisibility</strong>: A boolean indicating whether or not to track the visibility of the element.</li>\n<li><strong>delay</strong>: A number defining the minimum delay in milliseconds between notification for a given object.</li>\n</ul>\n<blockquote>\n<p>💡 Note that tracking visibility is an expensive operation and should only be used when necessary. The performance implications can cause more harm than good if abused.</p>\n</blockquote>\n<h2 id=\"how-does-it-determine-visibility\" style=\"position:relative;\"><a href=\"#how-does-it-determine-visibility\" aria-label=\"how does it determine visibility 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 does it determine visibility?</h2>\n<p>Determining whether the element is visible or not is not as simple as you might think. Based on the spec:</p>\n<ul>\n<li>If <code class=\"language-text\">false</code> is passed as the value of <code class=\"language-text\">trackVisibility</code>, the element is considered visible.</li>\n<li>If the target element has an effective transformation matrix other than <code class=\"language-text\">2D</code> then the element is considered invisible.</li>\n<li>If the target element or any of its children, has an effective capacity other than <code class=\"language-text\">1.0</code>, then it’s considered invisible.</li>\n<li>If the target element or any of its children has a filter applied, then it’s considered invisible.</li>\n<li>If the browser cannot guarantee the target is fully visible, then it’s considered invisible.</li>\n</ul>\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>This is in a draft state and still work in progress. Apart from Chrome, none of the other major browsers currently support it.</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>Although this hasn’t been implemented in most browsers yet, it’s a great tool to prevent some of the common attacks such as <code class=\"language-text\">clickjacking</code> or <code class=\"language-text\">likejacking</code>, or <code class=\"language-text\">cursorjacking</code>.</p>","timeToRead":2,"frontmatter":{"title":"Introducing the Intersection Observer V2 ⛌","unformattedDate":"2020-06-22T00:00:00.000Z","date":"Jun 22, 2020","path":"/Intersection-observer-v2/","author":"Yaser Adel Mehraban","tags":["showdev","webdev","javascript","intersectionobserver"],"thumbnail":null}}},{"node":{"id":"58b5aa93-3d99-5e38-80dc-701eef573c6a","html":"<p>I remember a while back (not sure how long), Chrome had the ability to save all tabs when you closed the browser regardless of whether it was by accident or not. But they removed that ability and now if you close the window you will lose the tabs.</p>\n<!--more-->\n<h2 id=\"what-now\" style=\"position:relative;\"><a href=\"#what-now\" aria-label=\"what now 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 now?</h2>\n<p>Well there are still some ways you can save your current tabs and open them next time you open a new Chrome window.</p>\n<h2 id=\"1-small-hack-but-works-most-times-\" style=\"position:relative;\"><a href=\"#1-small-hack-but-works-most-times-\" aria-label=\"1 small hack but works most times  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. Small hack but works (most times 😁)</h2>\n<p>Open your task manager and kill the Chrome’s task. It’s a dirty hack but it works. When you open Chrome next time it asks you do you want to restore the last session and when you click the button, it will open all of your previously open tabs.</p>\n<p>So first kill the task:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 713px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/00050809776c4281b92e142067ba9f3c/def00/kill-chrome.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: 97.77777777777777%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAUABQDASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAAAAECAwX/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAv/aAAwDAQACEAMQAAAB603ioq3FYJvQH//EABoQAAICAwAAAAAAAAAAAAAAAAITAAEQEiD/2gAIAQEAAQUCSEUEUONr5//EABgRAAMBAQAAAAAAAAAAAAAAAAISUQAQ/9oACAEDAQE/AVGZRnf/xAAYEQACAwAAAAAAAAAAAAAAAAABEQAQUf/aAAgBAgEBPwFmM7f/xAAXEAADAQAAAAAAAAAAAAAAAAAAATEg/9oACAEBAAY/AoiIiLr/xAAZEAEAAwEBAAAAAAAAAAAAAAABABExEEH/2gAIAQEAAT8h9O1eXBZSMBreGwyf/9oADAMBAAIAAwAAABCEGAD/xAAYEQADAQEAAAAAAAAAAAAAAAAAAWGREP/aAAgBAwEBPxCDCTELn//EABURAQEAAAAAAAAAAAAAAAAAACBh/9oACAECAQE/ELif/8QAHRABAAMAAgMBAAAAAAAAAAAAAQARMSHRUXGh8P/aAAgBAQABPxASrC7d9xDfv3P3PcRWlw1hHtJvjIkNyzwROdZpMPU//9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Kill Chrome task in windows task manager\"\n        title=\"\"\n        src=\"/static/00050809776c4281b92e142067ba9f3c/def00/kill-chrome.jpg\"\n        srcset=\"/static/00050809776c4281b92e142067ba9f3c/6f81f/kill-chrome.jpg 270w,\n/static/00050809776c4281b92e142067ba9f3c/09d21/kill-chrome.jpg 540w,\n/static/00050809776c4281b92e142067ba9f3c/def00/kill-chrome.jpg 713w\"\n        sizes=\"(max-width: 713px) 100vw, 713px\"\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>Later when you open a new window:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 324px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/84095ac3a013789fa76de2ca2790f717/033fb/restore.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: 51.11111111111111%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAKABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAECBf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/9oADAMBAAIQAxAAAAHdVyiJK//EABoQAQACAwEAAAAAAAAAAAAAAAEAAhARITL/2gAIAQEAAQUCnIacW80AP//EABURAQEAAAAAAAAAAAAAAAAAAAAB/9oACAEDAQE/AUr/xAAWEQEBAQAAAAAAAAAAAAAAAAABABH/2gAIAQIBAT8BJMv/xAAZEAACAwEAAAAAAAAAAAAAAAAAARARITH/2gAIAQEABj8CLZjnh//EABsQAQACAgMAAAAAAAAAAAAAAAEAIRFBEFFx/9oACAEBAAE/Ib6iDRvKzCoT3gChMkoIL0T/2gAMAwEAAgADAAAAEP8A7//EABYRAQEBAAAAAAAAAAAAAAAAAAERAP/aAAgBAwEBPxBYXULv/8QAFhEBAQEAAAAAAAAAAAAAAAAAEQAB/9oACAECAQE/EMOkgv/EABkQAQEBAQEBAAAAAAAAAAAAAAERACExof/aAAgBAQABPxBvkJqVANcB93YMcpWPMapDolHOAppAN//Z'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Restore sessions in Chrome\"\n        title=\"\"\n        src=\"/static/84095ac3a013789fa76de2ca2790f717/033fb/restore.jpg\"\n        srcset=\"/static/84095ac3a013789fa76de2ca2790f717/6f81f/restore.jpg 270w,\n/static/84095ac3a013789fa76de2ca2790f717/033fb/restore.jpg 324w\"\n        sizes=\"(max-width: 324px) 100vw, 324px\"\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=\"2-save-them-as-bookmarks\" style=\"position:relative;\"><a href=\"#2-save-them-as-bookmarks\" aria-label=\"2 save them as bookmarks 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. Save them as bookmarks</h2>\n<p>Yes, you read right. You can save all open tabs as bookmarks and open them all later when you come back. Simply press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>d</kbd> in windows or <kbd>⌘</kbd> + <kbd>Shift</kbd> + <kbd>d</kbd> in Mac to save all your open tabs in a new bookmark folder.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 454px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/7c97dd161117ff703d6b13bc8cd4c85b/835f3/bookmarkall.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: 117.77777777777779%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAYABQDASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAAAAECAwX/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAv/aAAwDAQACEAMQAAAB7eiSAKFTcTX/xAAYEAACAwAAAAAAAAAAAAAAAAABAgAgQv/aAAgBAQABBQLVi4DT/8QAFhEBAQEAAAAAAAAAAAAAAAAAARAR/9oACAEDAQE/AYuT/8QAFxEAAwEAAAAAAAAAAAAAAAAAAQIQEf/aAAgBAgEBPwGKNn//xAAYEAACAwAAAAAAAAAAAAAAAAAQESAhkf/aAAgBAQAGPwJTV4P/xAAbEAABBAMAAAAAAAAAAAAAAAABEBEhMSBBYf/aAAgBAQABPyF4sNXrMAOR6T//2gAMAwEAAgADAAAAEODIfP/EABYRAQEBAAAAAAAAAAAAAAAAAAEQEf/aAAgBAwEBPxCMNJ//xAAWEQEBAQAAAAAAAAAAAAAAAAABEBH/2gAIAQIBAT8QgrGf/8QAHBAAAwEAAgMAAAAAAAAAAAAAAAERIRAxQWGR/9oACAEBAAE/ELWBbPHxb2Rmi4Yn4EZYpGLfch2f/9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Chrome bookmark all open tabs\"\n        title=\"\"\n        src=\"/static/7c97dd161117ff703d6b13bc8cd4c85b/835f3/bookmarkall.jpg\"\n        srcset=\"/static/7c97dd161117ff703d6b13bc8cd4c85b/6f81f/bookmarkall.jpg 270w,\n/static/7c97dd161117ff703d6b13bc8cd4c85b/835f3/bookmarkall.jpg 454w\"\n        sizes=\"(max-width: 454px) 100vw, 454px\"\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>Later on when you come back and open a new window, you can right click on the folder you created previously and select open all tabs:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 716px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/5ae22876b352406786c6a2512308e1c4/d80c4/open-all-bookmarks.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: 103.7037037037037%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAVABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAECBf/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAe9INAgNA//EABkQAAIDAQAAAAAAAAAAAAAAAAABAhARQf/aAAgBAQABBQK8FHHXT//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQMBAT8BH//EABQRAQAAAAAAAAAAAAAAAAAAACD/2gAIAQIBAT8BH//EABYQAQEBAAAAAAAAAAAAAAAAACABMf/aAAgBAQAGPwIXT//EAB4QAAICAAcAAAAAAAAAAAAAAAABESEQMUFRYYHw/9oACAEBAAE/IaOmTwz2yYJ23c4LPQbgI//aAAwDAQACAAMAAAAQo888/8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAwEBPxAf/8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAgEBPxAf/8QAIBABAAICAQQDAAAAAAAAAAAAAQARITFRYXGBkaHR8P/aAAgBAQABPxC1bnENuY/dYIKPi+5e2l9oDHvaODsOvEL5fUzVmnEoA4mk/9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Chrome open all pages in bookmark folder\"\n        title=\"\"\n        src=\"/static/5ae22876b352406786c6a2512308e1c4/d80c4/open-all-bookmarks.jpg\"\n        srcset=\"/static/5ae22876b352406786c6a2512308e1c4/6f81f/open-all-bookmarks.jpg 270w,\n/static/5ae22876b352406786c6a2512308e1c4/09d21/open-all-bookmarks.jpg 540w,\n/static/5ae22876b352406786c6a2512308e1c4/d80c4/open-all-bookmarks.jpg 716w\"\n        sizes=\"(max-width: 716px) 100vw, 716px\"\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<blockquote>\n<p>⚠️ This technique won’t help you if your browser crashes for some reason.</p>\n</blockquote>\n<h2 id=\"3-i-am-too-tired-to-do-all-of-that\" style=\"position:relative;\"><a href=\"#3-i-am-too-tired-to-do-all-of-that\" aria-label=\"3 i am too tired to do all of that 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. I am too tired to do all of that</h2>\n<p>If you don’t want to open your task manager, or don’t want to use bookmarks, don’t worry. There are some extensions which can help you with that.</p>\n<h3 id=\"tab-session-manager\" style=\"position:relative;\"><a href=\"#tab-session-manager\" aria-label=\"tab session manager 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>Tab Session Manager</h3>\n<p><a href=\"https://chrome.google.com/webstore/detail/tab-session-manager/iaiomicjabeggjcfkbimgmglanimpnae?hl=en\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Tab Session Manager</a> is a Chrome extension which allows you to do:</p>\n<ul>\n<li>Save and restore windows and tabs</li>\n<li>Manage sessions with name and tags</li>\n<li>Auto save when window is closed</li>\n<li>Auto save at regular intervals</li>\n<li>Import and export sessions</li>\n<li>Compatibility with Firefox extension</li>\n<li>Cloud sync</li>\n</ul>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 640px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/b0bc166de7ab6fbf44731de9cd404bd4/c08c5/tabmanager.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: 62.5925925925926%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAECBf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/9oADAMBAAIQAxAAAAHtzRKpf//EABQQAQAAAAAAAAAAAAAAAAAAACD/2gAIAQEAAQUCX//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABUQAQEAAAAAAAAAAAAAAAAAACAx/9oACAEBAAY/Aov/xAAbEAADAAIDAAAAAAAAAAAAAAAAAREQITFBUf/aAAgBAQABPyF26ovqElB8kT6x/9oADAMBAAIAAwAAABD0D//EABURAQEAAAAAAAAAAAAAAAAAABAR/9oACAEDAQE/EIf/xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAbEAEAAwADAQAAAAAAAAAAAAABABEhMUFhcf/aAAgBAQABPxCplKrxCJGlvzqdJzuwXcUyc5s/YT//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Chrome Tab Session Manager extension\"\n        title=\"\"\n        src=\"/static/b0bc166de7ab6fbf44731de9cd404bd4/c08c5/tabmanager.jpg\"\n        srcset=\"/static/b0bc166de7ab6fbf44731de9cd404bd4/6f81f/tabmanager.jpg 270w,\n/static/b0bc166de7ab6fbf44731de9cd404bd4/09d21/tabmanager.jpg 540w,\n/static/b0bc166de7ab6fbf44731de9cd404bd4/c08c5/tabmanager.jpg 640w\"\n        sizes=\"(max-width: 640px) 100vw, 640px\"\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>It also has <a href=\"https://microsoftedge.microsoft.com/addons/detail/jkjjclfiflhpjangefhgfjhgfbhajadk\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Microsoft</a> Edge and <a href=\"https://addons.mozilla.org/ja/firefox/addon/tab-session-manager/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Firefox</a> versions which is great.</p>\n<h3 id=\"session-buddy\" style=\"position:relative;\"><a href=\"#session-buddy\" aria-label=\"session buddy 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>Session Buddy</h3>\n<p><a href=\"https://chrome.google.com/webstore/detail/session-buddy/edacconmaakjimmfgnblocblbcdcpbko?hl=en\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Session Buddy</a> is a popular extension with more than 24K installs. It will do all of the above for you automatically in one place. Whether your browser crashes or you choose to close it manually.</p>\n<p><a href=\"https://www.youtube.com/watch?v=wY4NKrD1DWQ\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img src=\"https://img.youtube.com/vi/wY4NKrD1DWQ/0.jpg\" alt=\"IMAGE ALT TEXT HERE\"></a></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>Hope this helps you from a possible disaster if you have millions of tabs open at a time. If you are a tab person, check out my other article on <a href=\"https://dev.to/yashints/chrome-arrange-your-tabs-with-tab-groups-267f\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">managing your tabs in Chrome here</a>. Until next time, 👋🏽.</p>","timeToRead":2,"frontmatter":{"title":"Chrome - where did save sessions go? 🤔","unformattedDate":"2020-06-17T00:00:00.000Z","date":"Jun 17, 2020","path":"/chrome-save-tabs/","author":"Yaser Adel Mehraban","tags":["showdev","webdev","chrome","savetabs"],"thumbnail":null}}},{"node":{"id":"e4b82b57-2f2d-556c-8080-63025c9b2b94","html":"<p>If you’re one of those people with so many tabs open than you can manage, read on.</p>\n<!--more-->\n<h2 id=\"the-why\" style=\"position:relative;\"><a href=\"#the-why\" aria-label=\"the why 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>The why</h2>\n<p>For those of you who have many tabs open all at the same time and are struggling to keep a tab on your tabs, the time has come to get a bit more organised using this new feature in Chrome called tab groups.</p>\n<p>The whole purpose has been to help users keep their tabs organised and easier to find them in their sea of open tabs.</p>\n<h2 id=\"how-can-i-do-it\" style=\"position:relative;\"><a href=\"#how-can-i-do-it\" aria-label=\"how can i do 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 can I do it?</h2>\n<p>Simply right click your tab and select <strong>Add tab to tab group</strong> option. Then there will be a dot right before your tab. Click on the dot, a pop up will open in which you can select a colour for your tab group, and name your group.</p>\n<p>If you are clicking on an existing group, you will have the following options in addition:</p>\n<ul>\n<li>Add a new tab to the group</li>\n<li>Ungroup tabs in a group</li>\n<li>Close group</li>\n<li>Move the group to a new window</li>\n<li>Send feedback if you have any</li>\n</ul>\n<p>I’ve demonstrated this in below video:</p>\n<p><img src=\"/3d90142e4896a499fa70ca6655e929ff/chrome-tabs.gif\" alt=\"Adding tabs to tab groups in Chrome\"></p>\n<h2 id=\"but-i-dont-see-the-option\" style=\"position:relative;\"><a href=\"#but-i-dont-see-the-option\" aria-label=\"but i dont see the option 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>But I don’t see the option</h2>\n<p>If you can’t see the option, don’t worry, just go to <code class=\"language-text\">chrome://flags</code>, then search for <code class=\"language-text\">tab groups</code> and enable the option. It’s still experimental, but you can use it now.</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>Hope this will help you to keep a tab on your tabs and till next time 👋🏽.</p>","timeToRead":1,"frontmatter":{"title":"Chrome - Arrange your tabs with tab groups 😍","unformattedDate":"2020-06-15T00:00:00.000Z","date":"Jun 15, 2020","path":"/chrome-tab-groups/","author":"Yaser Adel Mehraban","tags":["showdev","webdev","chrome","tabgroups"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAGABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAEF/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQACEAMQAAAB3KFB/8QAFxAAAwEAAAAAAAAAAAAAAAAAAAEREv/aAAgBAQABBQLKmURH/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFhABAQEAAAAAAAAAAAAAAAAAADEB/9oACAEBAAY/AomI/8QAGRAAAgMBAAAAAAAAAAAAAAAAAAERMWHB/9oACAEBAAE/IWmgUPIyH//aAAwDAQACAAMAAAAQAA//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/ED//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAZEAEAAwEBAAAAAAAAAAAAAAABABFRIdH/2gAIAQEAAT8QZIdYESHomJT4z//Z"},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/bfee17b55a0f5a23e44cd563538e0640/1509a/tabgroups.jpg","srcSet":"/static/bfee17b55a0f5a23e44cd563538e0640/a1fc4/tabgroups.jpg 750w,\n/static/bfee17b55a0f5a23e44cd563538e0640/bb684/tabgroups.jpg 1080w,\n/static/bfee17b55a0f5a23e44cd563538e0640/1509a/tabgroups.jpg 1102w","sizes":"(min-width: 1102px) 1102px, 100vw"},"sources":[{"srcSet":"/static/bfee17b55a0f5a23e44cd563538e0640/7bd67/tabgroups.webp 750w,\n/static/bfee17b55a0f5a23e44cd563538e0640/ae9e6/tabgroups.webp 1080w,\n/static/bfee17b55a0f5a23e44cd563538e0640/53728/tabgroups.webp 1102w","type":"image/webp","sizes":"(min-width: 1102px) 1102px, 100vw"}]},"width":1102,"height":307}}}}}},{"node":{"id":"e17ac429-5a2f-512f-9056-66626a7b7ec0","html":"<p>You probably have used fragments in links to point a link to a part of your page such as a heading. This technique is used in table of content for example and it’s a common pattern.</p>\n<!--more-->\n<h2 id=\"background\" style=\"position:relative;\"><a href=\"#background\" aria-label=\"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>Background</h2>\n<p>To extend the current support for scrolling to an anchor element in a page, the W3C have proposed a solution which basically adds the ability to link to a DOM element with id, or textual content on a page to make it easier for browsers to understand what the users are interested and scroll there when they visit the page. In addition to make it visually easier to follow, they have added the highlight to the text so that users will know where to look at on first sight.</p>\n<h2 id=\"scroll-to-text-fragment\" style=\"position:relative;\"><a href=\"#scroll-to-text-fragment\" aria-label=\"scroll to text fragment 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>Scroll to Text Fragment</h2>\n<p>So that’s how <a href=\"https://github.com/WICG/scroll-to-text-fragment\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Scroll to Text Fragment</a> was born. It has been shipped to Chrome and Microsoft Edge called <a href=\"https://github.com/WICG/scroll-to-text-fragment\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Scroll to Text Fragment</a> which allows you to link to a specific text on a page, using a fragment provided in the URL. When the page is loaded, the browser highlights the text and scrolls it into view.</p>\n<p>This is the generic syntax:</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-text line-numbers\"><code class=\"language-text\">#:~:text=[prefix-,]textStart[,textEnd][,-suffix]\r\n          context  |-------match-----|  context</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<blockquote>\n<p>💡 Square brackets indicate an optional parameter.</p>\n</blockquote>\n<p>Here is an example:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"24544895499245210000\"\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 href=&quot;https://yashints.dev/#:~:text=Meet&text=Yas&quot;>\r\n  Click to go to a specific portion of a page\r\n</a>`, `24544895499245210000`)\"\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> <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://yashints.dev/#:~:text=Meet&amp;text=Yas<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n  Click to go to a specific portion of a page\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></pre></div>\n<p>And you can test it live by <a href=\"https://yashints.dev#:~:text=Meet&#x26;text=Yas\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">clicking here</a>.</p>\n<p>If you want to target an exact text:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"50372966146058930000\"\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 href=&quot;https://yashints.dev/#:~:text=almond%20croissant%20addict&quot;>\r\n  Click to go to a specific portion of a page\r\n</a>`, `50372966146058930000`)\"\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> <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://yashints.dev/#:~:text=almond%20croissant%20addict<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n  Click to go to a specific portion of a page\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></pre></div>\n<p><a href=\"https://yashints.dev/#:~:text=almond%20croissant%20addict\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Try it here</a>.</p>\n<p>You can also add an end text in which case the text directive refers to a range of text on the page.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"92691127370110040000\"\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 href=&quot;https://yashints.dev/#:~:text=Although,web%20developer&quot;>\r\n  Click to go to a specific portion of a page\r\n</a>`, `92691127370110040000`)\"\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> <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://yashints.dev/#:~:text=Although,web%20developer<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n  Click to go to a specific portion of a page\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></pre></div>\n<p><a href=\"https://yashints.dev/#:~:text=Although,web%20developer\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Try it here</a>.</p>\n<h2 id=\"use-cases\" style=\"position:relative;\"><a href=\"#use-cases\" aria-label=\"use cases 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>Use cases</h2>\n<h3 id=\"search-engines\" style=\"position:relative;\"><a href=\"#search-engines\" aria-label=\"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>Search engines</h3>\n<p>When search engines will link to pages which contain relevant information to the query, they will scroll and highlight that so the user will find it easier.</p>\n<h3 id=\"citation--reference-links\" style=\"position:relative;\"><a href=\"#citation--reference-links\" aria-label=\"citation  reference links 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>Citation / Reference links</h3>\n<p>Links are sometimes used as citations on some pages where the author wishes to enforce a claim by pointing to a reference such as <em>Wikipedia</em>. These reference pages can contains large chunks of text and finding the information can be difficult. So having the ability to scroll to that section and highlight it is really encouraging to readers to follow the links.</p>\n<h3 id=\"sharing-a-specific-text-or-paragraph\" style=\"position:relative;\"><a href=\"#sharing-a-specific-text-or-paragraph\" aria-label=\"sharing a specific text or paragraph 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>Sharing a specific text or paragraph</h3>\n<p>Sometimes you want to share a piece of text to someone for example by email or on social media, it’s really helpful to be able to link directly to the specific section rather than the whole page.</p>\n<p>Nowadays people share short snippets directly in tweets or create screenshots which can contain more text and post those. With this they won’t need to do that since links can be more meaningful.</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>And that’s how the web is moving towards a better place where users are the centre of attention for us developers and the more we know how to make their lives easier the more they trust us to take care of it for them.</p>\n<p>Enjoy your evening and till next time 👋🏽.</p>","timeToRead":2,"frontmatter":{"title":"Did you know about scroll to text? 📜","unformattedDate":"2020-06-14T00:00:00.000Z","date":"Jun 14, 2020","path":"/scroll-to-text/","author":"Yaser Adel Mehraban","tags":["showdev","webdev","javascript","scrolltotext"],"thumbnail":null}}},{"node":{"id":"9507529c-b56d-5ca8-a624-65ac967832a6","html":"<p>I see some occasions where web developers who are a bit less familiar with accessibility use links incorrectly in different forms. So I thought let’s write a quick guide on <em>Links</em> in JavaScript apps.</p>\n<!--more-->\n<h2 id=\"background\" style=\"position:relative;\"><a href=\"#background\" aria-label=\"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>Background</h2>\n<p>It’s safe to assume that anyone who’s used the web have seen them. They take users from one page to another either within the same application or to an external website. There were really hot when they were introduced back in <strong>1966</strong> by a team led by <a href=\"https://en.wikipedia.org/wiki/Douglas_Engelbart\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Douglas Engelbart</a>.</p>\n<p>In the early 1980s <em>Ben Shneiderman</em>, a computer scientist at the University of Maryland, with his graduate student <em>Dan Ostroff</em> were preparing a videodisk exhibit for a museum. It was then where they used a caption that had all the information and users could click on it to see the photo associated with it.</p>\n<p>At first, this discovery was called <code class=\"language-text\">embedded menu</code> but that term was quickly replaced by <code class=\"language-text\">hyperlink</code>. <a href=\"https://en.wikipedia.org/wiki/Tim_Berners-Lee\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Tim Berners-Lee</a> cited Shneiderman’s hyperlink work in his spring 1989 manifesto for what would become the World Wide Web.</p>\n<p>Back then, this feature was super hot and it still is. People use it without even thinking about it and it’s become a natural part of the web.</p>\n<h2 id=\"enough-background-tell-me-whats-this-all-about\" style=\"position:relative;\"><a href=\"#enough-background-tell-me-whats-this-all-about\" aria-label=\"enough background tell me whats this all about 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>Enough background, tell me what’s this all about</h2>\n<p>Let’s review what they do:</p>\n<ul>\n<li>As mentioned before they allow users to navigate between pages within a site or to an external one.</li>\n<li>And more importantly they help search engines and bots to find resources and going from one page to another by following the links. Think of this as a giant maze where they need to blindly follow the links to discover stuff.</li>\n<li>And last, the crawlers use them to understand the architecture of a site and the type of content they have. It’s a critical part of their decision making when assigning a page to a specific topic.</li>\n</ul>\n<h2 id=\"but-how-do-you-make-a-link\" style=\"position:relative;\"><a href=\"#but-how-do-you-make-a-link\" aria-label=\"but how do you make a link 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>But how do you make a link?</h2>\n<h3 id=\"code-classlanguage-textacode-tag-with-code-classlanguage-texthrefcode\" style=\"position:relative;\"><a href=\"#code-classlanguage-textacode-tag-with-code-classlanguage-texthrefcode\" aria-label=\"code classlanguage textacode tag with code classlanguage texthrefcode 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\">a</code> tag with <code class=\"language-text\">href</code></h3>\n<p>Turns out it’s not as straightforward as one might think. The simplest way to put a link on your site is to use a good old <code class=\"language-text\">&lt;a></code> tag with a <code class=\"language-text\">URL</code> which it points to in the <code class=\"language-text\">href</code> attribute.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"5600599628600445000\"\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 href=&quot;/elsewhere&quot;>A good link, YES ╰(*°▽°*)╯</a>`, `5600599628600445000`)\"\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> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>/elsewhere<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>A good link, YES ╰(*°▽°*)╯<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></pre></div>\n<h3 id=\"code-classlanguage-textacode-tag-with-code-classlanguage-texthrefcode-and-event-handler\" style=\"position:relative;\"><a href=\"#code-classlanguage-textacode-tag-with-code-classlanguage-texthrefcode-and-event-handler\" aria-label=\"code classlanguage textacode tag with code classlanguage texthrefcode and event handler 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\">a</code> tag with <code class=\"language-text\">href</code> and event handler</h3>\n<p>For those with special circumstances, they might sprinkle a little bit of JavaScript on top and use an event handler to navigate the user programmatically:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"23499111752792380000\"\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 href=&quot;/elsewhere&quot; onclick=&quot;goTo('elsewhere')&quot;>Okay ¯\\_(ツ)_/¯</a>`, `23499111752792380000`)\"\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> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>/elsewhere<span class=\"token punctuation\">\"</span></span> <span class=\"token special-attr\"><span class=\"token attr-name\">onclick</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span><span class=\"token value javascript language-javascript\"><span class=\"token function\">goTo</span><span class=\"token punctuation\">(</span><span class=\"token string\">'elsewhere'</span><span class=\"token punctuation\">)</span></span><span class=\"token punctuation\">\"</span></span></span><span class=\"token punctuation\">></span></span>Okay ¯\\_(ツ)_/¯<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></pre></div>\n<p>This is fine as the link stays functional and you can upgrade the functionality using JavaScript.</p>\n<h3 id=\"code-classlanguage-textacode-tag-without-code-classlanguage-texthrefcode\" style=\"position:relative;\"><a href=\"#code-classlanguage-textacode-tag-without-code-classlanguage-texthrefcode\" aria-label=\"code classlanguage textacode tag without code classlanguage texthrefcode 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\">a</code> tag without <code class=\"language-text\">href</code></h3>\n<p>But some people decide to remove the <code class=\"language-text\">href</code> attribute. This is not a good idea because you now prevented crawlers to find out where this link goes to:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"67032642378138990000\"\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 onclick=&quot;goTo('elsewhere')&quot;>Please don't ╯︿╰</a>`, `67032642378138990000`)\"\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> <span class=\"token special-attr\"><span class=\"token attr-name\">onclick</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span><span class=\"token value javascript language-javascript\"><span class=\"token function\">goTo</span><span class=\"token punctuation\">(</span><span class=\"token string\">'elsewhere'</span><span class=\"token punctuation\">)</span></span><span class=\"token punctuation\">\"</span></span></span><span class=\"token punctuation\">></span></span>Please don't ╯︿╰<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></pre></div>\n<h3 id=\"code-classlanguage-textacode-tag-with-code-classlanguage-texthrefcode-but-no-link\" style=\"position:relative;\"><a href=\"#code-classlanguage-textacode-tag-with-code-classlanguage-texthrefcode-but-no-link\" aria-label=\"code classlanguage textacode tag with code classlanguage texthrefcode but no link 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\">a</code> tag with <code class=\"language-text\">href</code> but no link</h3>\n<p>In other occasions, people use the <code class=\"language-text\">href</code> attribute without a URL or with a pseudo URL:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"86821309195078480000\"\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 href=&quot;javascript:goTo('elsewhere')&quot;>Seriously? (⊙_⊙)？</a>`, `86821309195078480000`)\"\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> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>javascript:goTo('elsewhere')<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Seriously? (⊙_⊙)？<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></pre></div>\n<p>This is even worse than the previous case as it just confuses the hell out of every crawler out there.</p>\n<h3 id=\"using-code-classlanguage-textbuttoncode\" style=\"position:relative;\"><a href=\"#using-code-classlanguage-textbuttoncode\" aria-label=\"using code classlanguage textbuttoncode 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>using <code class=\"language-text\">button</code></h3>\n<p>You might think it’s a good idea to use a button to navigate the user, but let me tell you, that’s not a good idea either. The rule of thumb is that if the purpose is to do something on the current page, it could be a button. But if it’s takes users to another page or to an external site, it should be a link.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"74968693135261970000\"\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(`<button onclick=&quot;goTo('elsewhere')&quot;>But why? <( _ _ )> </button>`, `74968693135261970000`)\"\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>button</span> <span class=\"token special-attr\"><span class=\"token attr-name\">onclick</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span><span class=\"token value javascript language-javascript\"><span class=\"token function\">goTo</span><span class=\"token punctuation\">(</span><span class=\"token string\">'elsewhere'</span><span class=\"token punctuation\">)</span></span><span class=\"token punctuation\">\"</span></span></span><span class=\"token punctuation\">></span></span>But why? <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>(</span> <span class=\"token attr-name\">_</span> <span class=\"token attr-name\">_</span> <span class=\"token attr-name\">)</span><span class=\"token punctuation\">></span></span> <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>button</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<h3 id=\"any-other-html-element\" style=\"position:relative;\"><a href=\"#any-other-html-element\" aria-label=\"any other html element 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>any other HTML element</h3>\n<p>It’s worth noting that you shouldn’t simulate a link using any other HTML element and add a click handler with JavaScript:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"68165252318563580000\"\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(`<div onclick=&quot;goTo('elsewhere')&quot;>NOOOOOOOOOOOOOOOO!!!!!!!!!!!! (#\\`O′)</div>`, `68165252318563580000`)\"\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>div</span> <span class=\"token special-attr\"><span class=\"token attr-name\">onclick</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span><span class=\"token value javascript language-javascript\"><span class=\"token function\">goTo</span><span class=\"token punctuation\">(</span><span class=\"token string\">'elsewhere'</span><span class=\"token punctuation\">)</span></span><span class=\"token punctuation\">\"</span></span></span><span class=\"token punctuation\">></span></span>NOOOOOOOOOOOOOOOO!!!!!!!!!!!! (#`O′)<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</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>This not only wrong for crawlers, but also messes up the screen readers and causes a lot of trouble for people with any vision impairment. So please just use a link with a proper URL.</p>\n<h2 id=\"what-is-a-proper-url-i-hear-you-ask\" style=\"position:relative;\"><a href=\"#what-is-a-proper-url-i-hear-you-ask\" aria-label=\"what is a proper url i hear you 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 is a proper URL? I hear you ask</h2>\n<p>You saw we ruled out the pseudo URLs like <code class=\"language-text\">javascript:doSomething()</code>, but let’s take a look at URLs more closely.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"92945146402635280000\"\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(`http://example.com/old-school-url\r\n\r\nexample.com/page#section`, `92945146402635280000`)\"\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=\"text\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-text line-numbers\"><code class=\"language-text\">http://example.com/old-school-url\r\n\r\nexample.com/page#section</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>A URL contains these elements:</p>\n<ul>\n<li>A protocol (optional), which defines the protocol to be used for navigation such as <code class=\"language-text\">http</code>, or <code class=\"language-text\">https</code>.</li>\n<li>It also has a host, <code class=\"language-text\">example.com</code> or <code class=\"language-text\">yashints.dev</code>. A host is a name that one or some computers respond to. Usually it points to an IP address.</li>\n<li>It has a path to specific asset on that computer such as an HTML file, an image, CSS file or a font. But that’s not always the case, sometimes the path is handled via JavaScript and is used to replace part of the content in a page. This technique is called Single Page Application or SPA.</li>\n<li>Some URLs might contain another part such the second example above. That part which comes after the <code class=\"language-text\">#</code> sign, is called a fragment identifier. By itself a fragment identifier is not a piece of content. It just points to a specific part in the content such as a header.</li>\n</ul>\n<blockquote>\n<p>💡 Because fragments are not suppose to point to different content, crawlers ignore them altogether. This means for single page applications where they use fragment like routing, crawlers don’t follow them and that’s why people use techniques such as server side rendering or SSR to allow crawlers become aware of the page’s content.</p>\n</blockquote>\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>To sum it all up:</p>\n<ul>\n<li>Use proper link markup, <code class=\"language-text\">a</code> tag with <code class=\"language-text\">href</code> attribute.</li>\n<li>Do not use other HTML elements to navigate users.</li>\n<li>Do not omit the <code class=\"language-text\">href</code> attribute on an anchor tag.</li>\n<li>And last but not least, do not use fragment identifiers to load different content in SPAs if you can.</li>\n</ul>\n<p>Hope you’ve enjoyed reading this and thanks for drooping by. Until next article, Ta.</p>","timeToRead":4,"frontmatter":{"title":"Links and JavaScript 🔗","unformattedDate":"2020-06-03T00:00:00.000Z","date":"Jun 03, 2020","path":"/links/","author":"Yaser Adel Mehraban","tags":["showdev","webdev","javascript","links"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAALABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAIDBf/EABYBAQEBAAAAAAAAAAAAAAAAAAECA//aAAwDAQACEAMQAAAB2kolFjANj//EABsQAAIBBQAAAAAAAAAAAAAAAAECAwAQEiEx/9oACAEBAAEFAgAtRvlYdk1GWZj/AP/EABURAQEAAAAAAAAAAAAAAAAAAAAR/9oACAEDAQE/AVf/xAAYEQACAwAAAAAAAAAAAAAAAAAAEyExYf/aAAgBAgEBPwG4Eaf/xAAaEAEAAgMBAAAAAAAAAAAAAAABABECEDES/9oACAEBAAY/AnySnu8k7UtWf//EABsQAAICAwEAAAAAAAAAAAAAAAABESEQMXFB/9oACAEBAAE/IUsNN30tohMbB9f9CUE+n//aAAwDAQACAAMAAAAQ/wAf/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPxAf/8QAGBEBAQADAAAAAAAAAAAAAAAAAQARITH/2gAIAQIBAT8QNsusOf/EABsQAQEAAgMBAAAAAAAAAAAAAAERACEQMUGR/9oACAEBAAE/EFumQEFNY69vknBmx+40oTQG+scLE9Gf/9k="},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/ded954c9096452afa1ce0e02c9b7791f/84808/link.jpg","srcSet":"/static/ded954c9096452afa1ce0e02c9b7791f/9e0f0/link.jpg 750w,\n/static/ded954c9096452afa1ce0e02c9b7791f/84808/link.jpg 960w","sizes":"(min-width: 960px) 960px, 100vw"},"sources":[{"srcSet":"/static/ded954c9096452afa1ce0e02c9b7791f/cbeef/link.webp 750w,\n/static/ded954c9096452afa1ce0e02c9b7791f/f07e3/link.webp 960w","type":"image/webp","sizes":"(min-width: 960px) 960px, 100vw"}]},"width":960,"height":540}}}}}},{"node":{"id":"55d486ce-6cdf-536f-9251-83e8572adea6","html":"<p><a href=\"https://mybuild.microsoft.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Microsoft Build</a> went on fully online and it came with some really exciting announcements. For us developers some of these can bring massive efficiencies. So let’s see what’s on offer.</p>\n<!--more-->\n<h2 id=\"wsl2\" style=\"position:relative;\"><a href=\"#wsl2\" aria-label=\"wsl2 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>WSL2</h2>\n<p><a href=\"https://docs.microsoft.com/en-us/windows/wsl/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Windows Subsystem for Linux v2 (aka WSL2)</a> is here with a ton of awesome features allowing developers to have a really great experience working in a side by side Windows/Linux environment.</p>\n<ul>\n<li>No Hyper-V image is needed to run docker containers</li>\n<li>GPU Support</li>\n<li>100% system call compatibility</li>\n<li>Increased I/O performance</li>\n</ul>\n<h2 id=\"linux-gui-apps-in-windows\" style=\"position:relative;\"><a href=\"#linux-gui-apps-in-windows\" aria-label=\"linux gui apps in windows 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>Linux GUI apps in Windows</h2>\n<p>This was really an exciting announcements. Microsoft is adding a full Linux Kernel to its <a href=\"https://docs.microsoft.com/en-us/windows/wsl/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Windows Subsystem for Linux v2 (aka WSL2)</a> with GUI support and GPU acceleration.</p>\n<p>This will be enabled without us having to use X11 forwarding and it’s mainly designed for developers to run Linux integrated development environments alongside regular Windows apps.</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/65b15eb608f5c4b3c8e1f45c40411cb3/29114/WSLGUIAppsNoName.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: 56.29629629629629%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAABnWAAAZ1gEY0crtAAACf0lEQVR42oWSy0tUYRTAvyiynVgoGdW/UIuWURSuWrZyUas2rqJltAl7mFQUhJhFr8EcNbOHaWGJJkYJpUL2UEdtUGfmzp3nnevMfc2dX2es3BT0we9+F845P8459yoVtFFBC9UuBAqoe3nUbRPVkkZdS6AuaajGCOpMGHUqhGr4hjo2iTo6jjryDlU3ijo8gjo4xIb9r1GqS4TdNpU9eaq6TSo7slQ9zFETzFMdMKm5k6O6JcnWyzFqG+fYdXqCuitfqb/xjfrrwtUv7Dk5xu4Tw+w6Xhb2OGzutRkJaWi6ztT3eSa+zjIbjjC/FCUUXmJ6ZpZP0zNMzS2xHIkQjUWIaSskdQ3DSKMl4qSNFJOzURH2ulQ8dxhfiGFJ0C36pNNp3n8YZzUVJ7UyR1b7QSq+Qsxw0LWyMIqRMzEFx3Hx/RLyYG7JEOEzjy0vPCZXUuQlwdAXMJMiyBjYVgHbcUQYJhmPoJkeuh4hm01j2w6u64rQwbIsKPmElnMi7POoGHCZ1k18CSaiITJ6WEQuBRFaUpjPJshkUkQNG8918LyiNOSvU5SpymcxsirCfhG+8vgcz4FrEVpcJiy7K59yMiUZhxKOFGmGxb/OWsq6cKBExaDP94QJBdmJbVEqemsjrIMvu/WI5ez/CM1fHW4ccNg3mufAmPCuILfwVt6HhcEch15m2dudpPVjQso8HBm5WPyDLyv4NXJoufxRhkANC0O/eSMMCv3CE6HTZ1NA/tXrqzSN59cKf9f/1eFCeeTtzS+ovdhLbVMvNY3d1Jx7xLYLT6lq6mNncx87zkv87ACbGgLUNwdp7+ii9X4nbQ+6uHmvc41bgce03Q1yuSXITwrK0wP0OV5KAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Linux GUI in Windows Subsystem for Linux\"\n        title=\"\"\n        src=\"/static/65b15eb608f5c4b3c8e1f45c40411cb3/302a4/WSLGUIAppsNoName.png\"\n        srcset=\"/static/65b15eb608f5c4b3c8e1f45c40411cb3/01bf6/WSLGUIAppsNoName.png 270w,\n/static/65b15eb608f5c4b3c8e1f45c40411cb3/07484/WSLGUIAppsNoName.png 540w,\n/static/65b15eb608f5c4b3c8e1f45c40411cb3/302a4/WSLGUIAppsNoName.png 1080w,\n/static/65b15eb608f5c4b3c8e1f45c40411cb3/0d292/WSLGUIAppsNoName.png 1620w,\n/static/65b15eb608f5c4b3c8e1f45c40411cb3/29114/WSLGUIAppsNoName.png 1920w\"\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>\r\n<em>Image from <a href=\"https://devblogs.microsoft.com/commandline/the-windows-subsystem-for-linux-build-2020-summary/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Microsoft’s official blog</a></em></p>\n<h2 id=\"winget-microsofts-package-manager\" style=\"position:relative;\"><a href=\"#winget-microsofts-package-manager\" aria-label=\"winget microsofts package manager 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>Winget, Microsoft’s package manager</h2>\n<p>This is probably one of those controversial topics where people will say: oh another package manager. But Microsoft believes they have considered all options and this decision was made with lots of considerations.</p>\n<p>You can install <code class=\"language-text\">winget</code> via it’s <a href=\"https://www.microsoft.com/en-us/p/app-installer/9nblggh4nns1\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">App Installer</a> package. You can also join their insider program which contains the <code class=\"language-text\">winget</code> by default.</p>\n<p>You can easily add your package to this package manager by following their instructions on their <a href=\"https://github.com/microsoft/winget-pkgs\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GitHub repository</a> and create a PR containing your package’s information and link to download.</p>\n<p>Just so you know how excited people are, there are already <a href=\"https://github.com/microsoft/winget-pkgs/pulls\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><strong>228</strong> open PR’s</a> and 541 closed. Of course not all of those PR’s have been packages, but even so, it’s a lot of packages submitted already.</p>\n<h2 id=\"microsofts-new-powertoys-run-launcher\" style=\"position:relative;\"><a href=\"#microsofts-new-powertoys-run-launcher\" aria-label=\"microsofts new powertoys run launcher 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>Microsoft’s new PowerToys Run launcher</h2>\n<p>Microsoft just released a new Spotlight-like launcher app for Windows 10. This launcher is part of a series of apps which come with the PowerToys tool set.</p>\n<p>It’s still preview, but you can install it today. Jump into <a href=\"https://github.com/microsoft/PowerToys/releases\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">this page</a> and download the <code class=\"language-text\">msi</code> file, then install it.</p>\n<p>Or if you like to do it a bit more fancy, just run this in your terminal:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"73882174202224000000\"\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(`WinGet install powertoys`, `73882174202224000000`)\"\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\">WinGet <span class=\"token function\">install</span> powertoys</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Remember this requires <code class=\"language-text\">winget</code> to be installed to work.</p>\n<p>Once installed, press <kbd>Alt</kbd> + <kbd>Space</kbd> and you’ll get this beautiful launcher:</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/cbddaf64a1326b5ade9c3837f1d05fbf/f04cb/powertoys.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.148148148148145%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAKABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAEEBf/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAZa8ZDEH/8QAGBABAQADAAAAAAAAAAAAAAAAAwIBBCD/2gAIAQEAAQUC1owlOBwPH//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABoQAAICAwAAAAAAAAAAAAAAAAECABEgUXH/2gAIAQEABj8CIbUZhV9x/8QAGhAAAgIDAAAAAAAAAAAAAAAAAREAICFBUf/aAAgBAQABPyFFiGxmEG4Vf//aAAwDAQACAAMAAAAQ9M//xAAVEQEBAAAAAAAAAAAAAAAAAAAQEf/aAAgBAwEBPxCn/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPxA//8QAHRABAAIBBQEAAAAAAAAAAAAAAQARMRAhQVFhof/aAAgBAQABPxBaVYLDnxJZEESw5DFxpcfYqm6yjo0//9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Powertoys run launcher\"\n        title=\"\"\n        src=\"/static/cbddaf64a1326b5ade9c3837f1d05fbf/47311/powertoys.jpg\"\n        srcset=\"/static/cbddaf64a1326b5ade9c3837f1d05fbf/6f81f/powertoys.jpg 270w,\n/static/cbddaf64a1326b5ade9c3837f1d05fbf/09d21/powertoys.jpg 540w,\n/static/cbddaf64a1326b5ade9c3837f1d05fbf/47311/powertoys.jpg 1080w,\n/static/cbddaf64a1326b5ade9c3837f1d05fbf/0047d/powertoys.jpg 1620w,\n/static/cbddaf64a1326b5ade9c3837f1d05fbf/274e1/powertoys.jpg 2160w,\n/static/cbddaf64a1326b5ade9c3837f1d05fbf/f04cb/powertoys.jpg 2955w\"\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<blockquote>\n<p>💡 You need to run it manually for the first time for now. This will get fixed once they release their GA version.</p>\n</blockquote>\n<p>Alongside <em>PowerToys Run</em>, Microsoft also released a Keyboard Manager PowerToy which allows you to define shortcuts for your favourite actions, or remap keys like replacing <code class=\"language-text\">A</code> with <code class=\"language-text\">B</code>. Check out the other cool tools in their <a href=\"https://github.com/microsoft/PowerToys\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GitHub page</a>.</p>\n<h2 id=\"project-reunion\" style=\"position:relative;\"><a href=\"#project-reunion\" aria-label=\"project reunion 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>Project Reunion</h2>\n<p>Microsoft announced <a href=\"https://github.com/microsoft/ProjectReunion\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Project Reunion</a>, an effort to bring <code class=\"language-text\">win32</code> desktop apps and its Universal Windows Platform (UWP) apps close together. From their page:</p>\n<blockquote>\n<p>Project Reunion makes it easier to build a great Windows app by providing a unified platform for new and existing Win32 and UWP apps. It will unify access to existing Win32 and UWP APIs and make them available decoupled from the OS, via tools like NuGet.</p>\n</blockquote>\n<p><img src=\"/68d2414da2d828e78d6ac2dbad1afb3c/projectreunion.gif\" alt=\"Project Reunion\"></p>\n<h2 id=\"fluid-framework\" style=\"position:relative;\"><a href=\"#fluid-framework\" aria-label=\"fluid framework 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>Fluid framework</h2>\n<p>Microsoft is adding a new type of document to it’s Office suite called <a href=\"https://techcommunity.microsoft.com/t5/microsoft-365-blog/introducing-the-first-microsoft-fluid-framework-experiences-in/ba-p/1345543\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Fluid Framework</a>. This allows multiple people to collaborate on a single document with fast speed and offers multiple types of elements like tables, graphs and lists in one place rather than having to use multiple apps for different reasons.</p>\n<p>Apart from aforementioned features, it comes with ability to @mention someone to notify them of something, plus activity feeds for each document if you want to be notified of the changes.</p>\n<p>And to emphasise their focus in bringing more to open source, they are making this framework open too.</p>\n<h2 id=\"project-bonsai\" style=\"position:relative;\"><a href=\"#project-bonsai\" aria-label=\"project bonsai 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>Project Bonsai</h2>\n<p><a href=\"https://blogs.microsoft.com/ai-for-business/build-bonsai-public-preview/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Project Bonsai</a> is Microsoft’s effort in creating a platform which lets developers and engineers create autonomous systems. It is a machine teaching service to create and optimize intelligence for industrial control systems. Through machine teaching, subject matter experts without an AI background can break down their expertise into steps and tasks that are imparted to AI agents.</p>\n<h2 id=\"static-web-apps\" style=\"position:relative;\"><a href=\"#static-web-apps\" aria-label=\"static web apps 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>Static Web Apps</h2>\n<p><a href=\"https://docs.microsoft.com/en-us/azure/static-web-apps/overview\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Static Web Apps</a> offers static Web applications powered by storage for hosting and Azure Functions as backend APIs. They also have the full pipeline on GitHub using GitHub actions to let you deploy your apps really fast.</p>\n<p>These are some of the key features:</p>\n<ul>\n<li><strong>Free web hosting</strong> for static content like HTML, CSS, JavaScript, and images.</li>\n<li><strong>Integrated API</strong> support provided by Azure Functions.</li>\n<li><strong>First-party GitHub integration</strong> where repository changes trigger builds and deployments.</li>\n<li><strong>Globally distributed</strong> static content, putting content closer to your users.</li>\n<li><strong>Free SSL certificates</strong>, which are automatically renewed.</li>\n<li><strong>Custom domains</strong> to provide branded customizations to your app.</li>\n<li><strong>Seamless security model</strong> with a reverse-proxy when calling APIs, which requires no CORS configuration.</li>\n<li><strong>Authentication provider integrations</strong> with Azure Active Directory, Facebook, Google, GitHub, and Twitter.</li>\n<li><strong>Customizable authorization role definition</strong> and assignments.</li>\n<li><strong>Back-end routing rules</strong> enabling full control over the content and routes you serve.</li>\n<li><strong>Generated staging versions</strong> powered by pull requests enabling preview versions of your site before publishing.</li>\n</ul>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 891px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/5aac7a911467f485db2f4e201d2cee65/b7877/static-apps-overview.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: 43.7037037037037%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAABJ0lEQVR42pVSW26EMAzk/hfpDVZUosfoflWqBAgtDc8AIeGR2Uy6Qajbj9aSFTu2x2MnkbUW+76DMgwDvsoSbdt63bYNjIecfV0gBg0xahhjoLSBdifzKFVVIaLBAkqapnhLErzGMeLLBW3TIMR35tgNyafEy7XDR6PxLmb0yjDB59V1/Q0YJLA5mjzs4K/rimVZPLPZqXE2/TDhAWh/FD4BnwC11qgrgfJ2Q991/u4J8C9CWO6Ke8rzHFmWoQuA55GllD6JAS6aD6OU8j6VcfpkQXbTOEL2vVfehxqCCyEQ9S7QuOUzmUqfujz2w9dmAdmpafLALKZt2WSe/eOV7nd4QPxDwr5Gx5JNaPPOnkeeXCcm8Az2bz6VzMnuUMeeJ8E5XVEUuAO5LLsLEx1vPQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Azure Static Web Apps\"\n        title=\"\"\n        src=\"/static/5aac7a911467f485db2f4e201d2cee65/b7877/static-apps-overview.png\"\n        srcset=\"/static/5aac7a911467f485db2f4e201d2cee65/01bf6/static-apps-overview.png 270w,\n/static/5aac7a911467f485db2f4e201d2cee65/07484/static-apps-overview.png 540w,\n/static/5aac7a911467f485db2f4e201d2cee65/b7877/static-apps-overview.png 891w\"\n        sizes=\"(max-width: 891px) 100vw, 891px\"\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>\r\n<em>Image from Microsoft blog</em></p>\n<h2 id=\"others\" style=\"position:relative;\"><a href=\"#others\" aria-label=\"others 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>Others</h2>\n<p>There were dozens of other stuff announced, but here are some of the developer related ones:</p>\n<ul>\n<li>Blazer WASM is released</li>\n<li>MAUI makes mobile app development easier</li>\n<li>Visual Studio is becoming Visual Studio Codespaces</li>\n<li>GitHub Codespaces brings amazing developer experience right from your browser</li>\n<li>GitHub Discussions for brainstorming feature ideas, help new users</li>\n<li>Code scanning and secret scanning on GitHub on private repositories</li>\n<li>GitHub Private Instances – a fully managed environment for enterprises</li>\n<li>GitHub Actions for Azure are now integrated within: Visual Studio Code, Azure CLI, and the Azure Portal. This makes it easier to deploy from GitHub to Azure!</li>\n</ul>\n<p>Hope this has given you some pointers to go play with some of these amazing features and till next time 👋🏽.</p>","timeToRead":4,"frontmatter":{"title":"Microsoft Build 2020 highlights 🔣","unformattedDate":"2020-05-23T00:00:00.000Z","date":"May 23, 2020","path":"/build2020/","author":"Yaser Adel Mehraban","tags":["showdev","microsoft","build"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAABtUlEQVR42lWSYW/aMBCG8///wz5sH6tJkzpVg6K1pHRNqAqUMCgkISQkduz47DgMSlVN2s4GqlY6S+fzPeez73UoB1rJNyuFZMbUwcpKMag51OVbwtFBCpwTo97xqjyRstHDh/X4MYdG04884QeYAwOEFbFdoH/gKZf1bnN9Gf1yY3Rway88VsceHVymN6m5bIT+A81O1BtzZssLrWdTMp9TaBpMYKArtamUZpY3ML4KQ3r7gk5akHiVYhLFoqByBikpqQAkC1zPr5RXa2J6YhZWlWrq7X6z2/cfBt3rTrf7M8mKZF4nqcxX02jixxkNl+lwMnv5+8/3bsbB8AOM0TQn7o172Tr37++XWe63lqNRvvIupheffofZKIq+3PVAyvaPb2Ec2n5PcLPd9/t3nfb3ntuZPj3hPYtFcuuNWmdnM+8qTNZBmrbpuu/13G4np5QJwE9xzIOlLjkEwdj3vXj+SAefKWOVVJiSEcYkztlMu6AsmASLKMJnWxgcIwYwf0u4KFjFWL4afEUEz7AAN7OwsjnlYJxyYaTFLWyPlRWWURgVNdbGkZZHO2jOyMFUtA4a4fAfPGFL7CLoLwcAAAAASUVORK5CYII="},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/475d9ada33dde9cbf03e0d0b43005d41/f0d4e/build.png","srcSet":"/static/475d9ada33dde9cbf03e0d0b43005d41/f5ed6/build.png 750w,\n/static/475d9ada33dde9cbf03e0d0b43005d41/f0d4e/build.png 1024w","sizes":"(min-width: 1024px) 1024px, 100vw"},"sources":[{"srcSet":"/static/475d9ada33dde9cbf03e0d0b43005d41/58c96/build.webp 750w,\n/static/475d9ada33dde9cbf03e0d0b43005d41/dbb52/build.webp 1024w","type":"image/webp","sizes":"(min-width: 1024px) 1024px, 100vw"}]},"width":1024,"height":561}}}}}},{"node":{"id":"7dfe0f5f-240c-5739-80c3-b98d87efe202","html":"<p>There may be many different reasons why you’d want to swap two variables be it just changing two item’s location in an array or when sorting collections. The traditional way is just define a new variable, assign one value to it, put one of the items in the old place, then put the temp variable back in the new place. But my question is, is that the only way?</p>\n<!--more-->\n<h2 id=\"traditionally\" style=\"position:relative;\"><a href=\"#traditionally\" aria-label=\"traditionally 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>Traditionally</h2>\n<p>The old way of swapping two variables is done like below:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"6849296454621423000\"\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 x = &quot;Yas&quot;;\r\nlet y = &quot;Hints&quot;;\r\n\r\nlet temp = x;\r\nx = y;\r\ny = temp;\r\n\r\nconsole.log(x); // Hints\r\nconsole.log(y); // Yas`, `6849296454621423000`)\"\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=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\"><span class=\"token keyword\">let</span> x <span class=\"token operator\">=</span> <span class=\"token string\">\"Yas\"</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">let</span> y <span class=\"token operator\">=</span> <span class=\"token string\">\"Hints\"</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">let</span> temp <span class=\"token operator\">=</span> x<span class=\"token punctuation\">;</span>\r\nx <span class=\"token operator\">=</span> y<span class=\"token punctuation\">;</span>\r\ny <span class=\"token operator\">=</span> temp<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>x<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// Hints</span>\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>y<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// Yas</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>There is nothing wrong with this approach unless you’re doing it frequently.</p>\n<h2 id=\"without-the-temp-variable\" style=\"position:relative;\"><a href=\"#without-the-temp-variable\" aria-label=\"without the temp variable 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>Without the temp variable</h2>\n<p>There is another way you could swap two variables without any temp variable. But this only works with numbers:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"56234688476887286000\"\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 x = 10;\r\nlet y = 20;\r\n\r\nx = x + y;\r\ny = x - y\r\nx = x - y;\r\n\r\nconsole.log(x); // 20\r\nconsole.log(y); // 10`, `56234688476887286000`)\"\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=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\"><span class=\"token keyword\">let</span> x <span class=\"token operator\">=</span> <span class=\"token number\">10</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">let</span> y <span class=\"token operator\">=</span> <span class=\"token number\">20</span><span class=\"token punctuation\">;</span>\r\n\r\nx <span class=\"token operator\">=</span> x <span class=\"token operator\">+</span> y<span class=\"token punctuation\">;</span>\r\ny <span class=\"token operator\">=</span> x <span class=\"token operator\">-</span> y\r\nx <span class=\"token operator\">=</span> x <span class=\"token operator\">-</span> y<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>x<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// 20</span>\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>y<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// 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></pre></div>\n<p>This works two, but now we’re doing three additional operations to save some space, so you need to be careful when you use this one. Another thing to consider with this approach is the chance of having overflows with additions or subtractions (<code class=\"language-text\">sum</code> should be less than <code class=\"language-text\">Number.MAX_SAFE_INTEGER</code> which is <code class=\"language-text\">9007199254740991</code>).</p>\n<h2 id=\"bitwise-code-classlanguage-textxorcode\" style=\"position:relative;\"><a href=\"#bitwise-code-classlanguage-textxorcode\" aria-label=\"bitwise code classlanguage textxorcode 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>Bitwise <code class=\"language-text\">XOR</code></h2>\n<p>Similar to above approach, you could use <code class=\"language-text\">XOR</code> to swap the two variables, but this also works only on numbers:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"5780906262573881000\"\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 x = 3;\r\nlet y = 5;\r\n\r\nx = x ^ y;\r\ny = x ^ y;\r\nx = x ^ y;\r\n\r\nconsole.log(x); // 5\r\nconsole.log(y); // 3`, `5780906262573881000`)\"\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=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\"><span class=\"token keyword\">let</span> x <span class=\"token operator\">=</span> <span class=\"token number\">3</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">let</span> y <span class=\"token operator\">=</span> <span class=\"token number\">5</span><span class=\"token punctuation\">;</span>\r\n\r\nx <span class=\"token operator\">=</span> x <span class=\"token operator\">^</span> y<span class=\"token punctuation\">;</span>\r\ny <span class=\"token operator\">=</span> x <span class=\"token operator\">^</span> y<span class=\"token punctuation\">;</span>\r\nx <span class=\"token operator\">=</span> x <span class=\"token operator\">^</span> y<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>x<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// 5</span>\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>y<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// 3</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>If you’re not familiar with <code class=\"language-text\">XOR</code>, it works on bits. When you perform <code class=\"language-text\">XOR</code> two bits, it evaluates to <code class=\"language-text\">1</code> if they are different, and evaluates to <code class=\"language-text\">0</code> if they’re the same.</p>\n<table>\n<thead>\n<tr>\n<th align=\"center\">x</th>\n<th align=\"center\">y</th>\n<th align=\"center\">XOR</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td align=\"center\">0</td>\n<td align=\"center\">0</td>\n<td align=\"center\">0</td>\n</tr>\n<tr>\n<td align=\"center\">1</td>\n<td align=\"center\">1</td>\n<td align=\"center\">0</td>\n</tr>\n<tr>\n<td align=\"center\">0</td>\n<td align=\"center\">1</td>\n<td align=\"center\">1</td>\n</tr>\n<tr>\n<td align=\"center\">1</td>\n<td align=\"center\">0</td>\n<td align=\"center\">1</td>\n</tr>\n</tbody>\n</table>\n<p>So let’s see why this works.</p>\n<ol>\n<li><code class=\"language-text\">x = x ^ y</code></li>\n<li><code class=\"language-text\">y = y ^ x</code> when <code class=\"language-text\">x = (x ^ y)</code>, so the <code class=\"language-text\">y = (x ^ y) ^ y</code> which equals to <code class=\"language-text\">x ^ (y ^ y) = x ^ 0 = x</code>. So now our <code class=\"language-text\">y</code> is the old <code class=\"language-text\">x</code>.</li>\n<li><code class=\"language-text\">x = x ^ y</code> when according to our first step <code class=\"language-text\">x</code> is not <code class=\"language-text\">x ^ y</code>, and so <code class=\"language-text\">x = (x ^ y) ^ x = y ^ (x ^ x) = y ^ 0 = y</code>.</li>\n</ol>\n<p>Is this better than the previous one, probably faster, but still limited to numbers only.</p>\n<h2 id=\"es6-destructuring\" style=\"position:relative;\"><a href=\"#es6-destructuring\" aria-label=\"es6 destructuring 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>ES6 destructuring</h2>\n<p>Destructuring is an <code class=\"language-text\">ES6</code> feature which is used a lot in many of the modern frameworks. In its core, it allows you to store array elements in variables.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"90227155748721310000\"\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 x;\r\nlet y;\r\n\r\n[x, y] = [1, 2, 3];\r\n\r\nconsole.log(x); // 1\r\nconsole.log(y); // 2`, `90227155748721310000`)\"\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=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\"><span class=\"token keyword\">let</span> x<span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">let</span> y<span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token punctuation\">[</span>x<span class=\"token punctuation\">,</span> y<span class=\"token punctuation\">]</span> <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>\r\n\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>x<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// 1</span>\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>y<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// 2</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>Now considering how we can use this to swap the elements of an array:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"82861628946478800000\"\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 x = &quot;Yas&quot;;\r\nlet y = &quot;Hints&quot;;\r\n\r\n[x, y] = [y , x];\r\n\r\nconsole.log(x); // Hints\r\nconsole.log(y); // Yas`, `82861628946478800000`)\"\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=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\"><span class=\"token keyword\">let</span> x <span class=\"token operator\">=</span> <span class=\"token string\">\"Yas\"</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">let</span> y <span class=\"token operator\">=</span> <span class=\"token string\">\"Hints\"</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token punctuation\">[</span>x<span class=\"token punctuation\">,</span> y<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">[</span>y <span class=\"token punctuation\">,</span> x<span class=\"token punctuation\">]</span><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>x<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// Hints</span>\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>y<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// Yas</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>This method is much elegant, but still creates two arrays to perform the swapping. So the efficiency might not be that good if you’re swapping many elements.</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>Just because a feature is available, doesn’t mean you should use it in every situation. Think about what is the most important factor in the solution you’re implementing. If it’s space, choose one which doesn’t take much, although it’s a bit slower.</p>\n<p>If the memory doesn’t matter but speed is important, choose accordingly. But definitely consider the situation before deciding on your approach.</p>","timeToRead":2,"frontmatter":{"title":"Swapping variables in JavaScript 🔁","unformattedDate":"2020-05-15T00:00:00.000Z","date":"May 15, 2020","path":"/swap/","author":"Yaser Adel Mehraban","tags":["showdev","webdev","javascript","swap"],"thumbnail":null}}}]}},"pageContext":{"limit":10,"skip":20,"numPages":13,"currentPage":3}},"staticQueryHashes":[],"slicesMap":{}}