<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>DevApt Feed</title>
        <link>https://devapt.com</link>
        <description>Welcome to DevApt</description>
        <lastBuildDate>Sun, 22 Nov 2026 14:21:25 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>NextJS feed</generator>
        <language>en</language>
        <image>
            <title>DevApt Feed</title>
            <url>https://res.cloudinary.com/cloudtale/image/upload/v1639579845/devapt/DevApt.png</url>
            <link>https://devapt.com</link>
        </image>
        <copyright>All rights reserved 2026, DevApt</copyright>
        <item>
            <title><![CDATA[Free FormSpree alternative to handle forms on static sites]]></title>
            <link>https://devapt.com/formspree-alternative-formeasy</link>
            <guid isPermaLink="false">https://devapt.com/formspree-alternative-formeasy</guid>
            <pubDate>Tue, 07 Jun 2022 08:44:31 GMT</pubDate>
            <description><![CDATA[Here is the free and open source formspree alternative to handle contact forms on static websites.
You can have full control of your data. ]]></description>
            <content:encoded><![CDATA[<p>In the early days of the internet, the information on the web consisted of just static pages. When it became interactive people started generating web pages on the server, making them more dynamic in nature.&nbsp;</p>
<p>With the advent of new technologies and site generators, a new philosophy of serving web pages is making us think about static pages again.&nbsp;</p>
<p>This new philosophy or architecture is called JAMstack which stands for JavaScript, APIs and Markdown stack.</p>
<p>The whole idea of JAMstack is to serve websites as static pages, giving dynamic nature using JavaScript, and exchange data through APIs.&nbsp;</p>
<p>As a result, it makes the developer experience simpler, improves performance with greater scalability, and reduces the cost of maintenance.&nbsp;</p>
<p>There are many static site generators available these days viz., NextJS, Hugo, Gatsby, etc.&nbsp;</p>
<p>With the help of third-party tools or services, these static sites can be made more dynamic.&nbsp;</p>
<p>Creating and maintaining static sites is inexpensive but adding dynamic features is where one has to spend on third-party tools.</p>
<p>One essential service which almost every website needs is a contact form and handling contact forms on static sites can be done through third-party services as we don't maintain a full-fledged server to handle forms on static sites.</p>
<p>Some of the static site form handling services are FormSpree, FormKeep, GetForm etc. These third-party services come at a price and free tier services have limitations in data and the number of submissions.&nbsp;</p>
<p>But here is a solution that helps you to handle forms on static sites without the need for these third-party tools.&nbsp;</p>
<p>It is called <strong>FormEasy</strong> which is a FREE and open-source apps script library that helps you to receive forms on static sites with full control of your data.</p>
<p>Form spree is a quite popular service for handling forms on static websites and <a href="https://devapt.com/formeasy" target="_blank" rel="noopener">FormEasy</a> can be the best formspree alternative with all customizations you want.</p>
<p>Let's see how to set up this FormEasy apps script library to handle static site forms.</p>
<h2 id="formeasy-setup" style="text-align: center;">FormEasy setup</h2>
<p>In a few simple steps, forms on static sites can be handled using FormEasy library.&nbsp;</p>
<ol>
<li>Create an empty Google sheets file</li>
<li>Open the Apps Script file connected to it</li>
<li>Add the FormEasy library using ScriptID</li>
<li>Add <code>doPost</code> apps script function</li>
<li>Deploy the apps script code and get the Web app URL to make POST requests</li>
</ol>
<h3 id="create_empty_google_sheet">1. Create an empty Google sheets file</h3>
<p>Visit this <a href="https://docs.google.com/spreadsheets/u/0/" target="_blank" rel="noopener">link</a> to create a new blank Google sheets file.</p>
<p><img src="../images/formeasy/create-empty-google-sheet.png" alt="Create-empty-Google-sheets-file-formeasy" /></p>
<h3 id="open_apps_script_file">2. Open the Apps Script file</h3>
<p>After creating an empty Google sheet file(you can rename the file if you want to), go to <strong><em>Extensions</em></strong> in the menu bar and click <em><strong>Apps Script</strong>.</em></p>
<p>It opens up an apps script file connected with the Google sheet.&nbsp;</p>
<p><img src="../images/formeasy/open-apps-script.png" alt="Open-apps-script-in-google-sheets" /></p>
<h3 id="add_formeasy_library">3. Add the FormEasy library</h3>
<p>In the left bar of apps script file click <code>+</code> button beside Libraries and add the below Script ID and click <strong><em>Look up</em></strong> button.</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%;">
<blockquote>ScriptID: 1CAyzGbXdwMlko81SbJAjRp7ewxhyGKhDipDK4v8ZvlpYqrMAAzbFNccL</blockquote>
</td>
</tr>
</tbody>
</table></div>
<p><img src="../images/formeasy/add-formeasy-library.png" alt="Add-FormEasy-library-to-apps-script" /></p>
<p>You will see two options <em>Version </em>and <em>Identifier</em>.&nbsp;</p>
<p>Select the latest version to reflect the latest changes made to the library if any or you can select the specific version as per the features you want.</p>
<p>For the identifier, the default name is <em>FormEasy</em> it is the name of the object used to call methods in the library. You can change it if you want but keeping it as it is can help you use the ready code snippets related to FormEasy.</p>
<h3 id="add_dopost_function">4. Add doPost function</h3>
<p>Clear the default functions if any in the default apps script file <em>Code.gs.</em></p>
<p>Create a function named <code>doPost</code>.&nbsp;</p>
<p><code>doPost</code> function name is the default name of the function that runs whenever a POST request is made to the script.</p>
<p>Next set the email if you want to get notified whenever any form gets submitted using <code>setEmail</code> method on FormEasy object. (FormEasy is the default identifier if you do not make any changes to the identifier while adding the FormEasy library)</p>
<p>Setting email is optional, the data gets logged in the Google sheet and you will not be notified through email if you do not set the email.</p>
<p>You need to return <code>action</code> method on FormEasy object with the <code>req</code> argument from the <strong><em>doPost</em></strong> function and this is the only mandatory method to use and all other methods on FormEasy are optional.&nbsp;</p>
<p><img src="../images/formeasy/add-formeasy-code.png" alt="Add-FormEasy-code" /></p>
<p>All the available methods on FormEasy library are:</p>
<div>
<ul>
<li><strong>setSheet</strong> - To select the specific sheet for saving the data(Default is active sheet)</li>
<li><strong>setEmail</strong> - To set the email for receiving notification</li>
<li><strong>setSubject </strong>- To set the subject of the email</li>
<li><strong>setFormHeading</strong> - To set the heading(inside email)</li>
<li><strong>setFields</strong> - To set the fields of the form(Lower case letters, also the keys of the JSON object)</li>
<li><strong>action</strong> - To return the response after submitting the form(Mandatory to return)</li>
</ul>
<p>The above all are optional methods except the <code>action</code>.</p>
<p>The simplest case looks like below:</p>
<pre class="language-javascript"><code>function doPost(req) {
  FormEasy.setEmail('youremail@domain.com'); // To receive email notification(optional)
  return FormEasy.action(req); // Mandatory to return action method
}</code></pre>
</div>
<h3 id="deploy_apps_script">5. Deploy the apps script code</h3>
<p>After saving all the changes to the code, it has to be deployed to use it.&nbsp;</p>
<p>To deploy, click the <strong>Deploy</strong> button at the top right corner and select&nbsp;<strong>New deployment</strong>&nbsp;and select type to&nbsp;<strong>Web app</strong>&nbsp;from the gear icon.</p>
<p dir="auto">Select/fill the below options</p>
<ul dir="auto">
<li>Description(optional),</li>
<li>Execute as&nbsp;<strong>Me(you email)</strong></li>
<li>Who has access&nbsp;<strong>Anyone</strong></li>
</ul>
<p>Click the <em>Deploy</em>&nbsp;button(authorize the script if you haven't done it before) and you will get a URL under&nbsp;<strong>Web app</strong>, copy that and it is going to be the endpoint for submitting the POST requests.&nbsp;</p>
<p>That's it. Now you can submit forms on this endpoint and they get logged in the Google sheet you selected. If you had set email then you will be notified through email whenever any form submission happens.</p>
<p><img src="../images/formeasy/deploy-apps-script.png" alt="Deploy-apps-script-code" /></p>
<p>If you want to make any changes to the script, like changing the subject text, email etc, you can do so and save the script. And while redeploying it instead of selecting <em>New deployment</em>, this time you have to select <strong>Manage deployments</strong> and click the pencil icon, select the <strong>New version,</strong> and click the deploy button.&nbsp;</p>
<p>The changes will be get reflected when you make the POST requests after that.&nbsp;</p>
<p><strong>Note:</strong> Whenever you make a new deployment, the web app URL changes. But when you redeploy using <strong><em>Manage deployments</em>&nbsp;</strong>option the URL remains the same.</p>
<p>Here is how a sample POST request using JavaScript <code>fetch</code> looks like.</p>
<pre class="language-javascript"><code>const data = {
  name: 'John',
  email: 'john@domain.com',
  message: 'Receiving forms is easy and simple now!',
};

const url = 'https://script.google.com/macros/s/&lt;Deployment ID&gt;/exec';

fetch(url, {
  method: 'POST',
  headers: {
    'Content-Type': 'text/plain;charset=utf-8',
  },
  body: JSON.stringify(data),
})
  .then((res) =&gt; res.json())
  .then((data) =&gt; console.log('data', data))
  .catch((err) =&gt; console.log('err', err));</code></pre>
<p>If you want to follow all the above instructions in the form of a video you can check this demo video.</p>
<div class="flex justify-center"><iframe class=" rounded-xl overflow-hidden" title="Text to image chrome extension intro" src="https://www.youtube-nocookie.com/embed/0u75mtnhifM?rel=0" width="680" height="350" frameborder="0" allowfullscreen="allowfullscreen"></iframe></div>
<p>As said already FormEasy is an open-source FormSpree alternative. You can check the source code of this library, fork it, make changes, use it yourself or you can contribute your code to the <a href="https://github.com/Basharath/FormEasy" target="_blank" rel="noopener">FormEasy Github repo</a>.</p>
<p>Hope this is a good solution to handle contact forms on static websites for FREE. If you have or found any such useful solution for static sites then do share it with us.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[100+ color names to use directly without needing hex color codes]]></title>
            <link>https://devapt.com/color-names-hex-color-codes</link>
            <guid isPermaLink="false">https://devapt.com/color-names-hex-color-codes</guid>
            <pubDate>Sat, 21 May 2022 09:15:37 GMT</pubDate>
            <description><![CDATA[Here are 100+ color names which you can directly use in your project without worrying about hex color codes. These are the w3c standard color names.]]></description>
            <content:encoded><![CDATA[<p>Colors play a vital role in making any form of art, design, or object conspicuous. Choosing or selecting colors sometimes could be a tedious job especially while prototyping.</p>
<p>The most commonly known colors are red, green, blue, yellow, orange, white, black, brown, violet, purple, and a few more.</p>
<p>We do not directly use the primary colors, RGB(Red, Green, Blue) in designing most of the things because they are strongly felt to the eyes, often they are used with <em>shades</em>(adding black to the original color), <em>tints</em>(adding white to the original color), or <em>tones</em>(adding gray or black &amp; white to the original color), that way they become more soothing to the eyes.&nbsp;</p>
<p>But adding shades or tints etc directly to the colors is a bit cumbersome task if we do not take the help of any color generating tool.&nbsp;</p>
<p>The good news is that there are about 100+ colors including the primary colors which we can directly use their color names in designing sites or apps. These color names are supported by almost all browsers and they have adjusted shades and tints unlike primary colors, which can help us avoid tinkering around hex color codes to generate appropriate shades or tints.</p>
<p>These 100+ color names are given by w3c(world wide web consortium), which means they're going to be supported by a wide variety of platforms.&nbsp;</p>
<p>As these are the standardized color names, we can even use those names with frameworks like TailwindCSS, e.g., bg-[mediumseagreen], bg-[gold], text-[lightseagreen], etc.&nbsp;</p>
<p>Below is the list of all color names along with their hex codes and RGB codes.&nbsp;</p>
<h2 id="html-color-names-with-hex-color-codes" style="text-align: center;">HTML color names with hex color codes</h2>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr>
<th style="border-style: solid; border-width: 2px; vertical-align: middle; text-align: left; width: 100.143%;" colspan="3">
<h3 id="white-color-names-and-codes" style="text-align: center;">White color names and codes</h3>
</th>
</tr>
<tr>
<th style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">Color name</th>
<th style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">Hex color code</th>
<th style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">RGB decimal code</th>
</tr>
<tr style="background-color: mistyrose;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;" width="92">MistyRose</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;" width="64">#FFE4E1</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;" width="140">(255, 228, 225)</td>
</tr>
<tr style="background-color: antiquewhite;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">AntiqueWhite</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#FAEBD7</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(250, 235, 215)</td>
</tr>
<tr style="background-color: linen;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">Linen</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#FAF0E6</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(250, 240, 230)</td>
</tr>
<tr style="background-color: beige;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">Beige</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#F5F5DC</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(245, 245, 220)</td>
</tr>
<tr style="background-color: whitesmoke;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">WhiteSmoke</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#F5F5F5</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(245, 245, 245)</td>
</tr>
<tr style="background-color: lavenderblush;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">LavenderBlush</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#FFF0F5</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(255, 240, 245)</td>
</tr>
<tr style="background-color: oldlace;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">OldLace</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#FDF5E6</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(253, 245, 230)</td>
</tr>
<tr style="background-color: aliceblue;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">AliceBlue</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#F0F8FF</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(240, 248, 255)</td>
</tr>
<tr style="background-color: seashell;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">Seashell</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#FFF5EE</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(255, 245, 238)</td>
</tr>
<tr style="background-color: ghostwhite;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">GhostWhite</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#F8F8FF</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(248, 248, 255)</td>
</tr>
<tr style="background-color: honeydew;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">Honeydew</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#F0FFF0</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(240, 255, 240)</td>
</tr>
<tr style="background-color: floralwhite;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">FloralWhite</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#FFFAF0</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(255, 250, 240)</td>
</tr>
<tr style="background-color: #f0ffff;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">Azure</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#F0FFFF</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(240, 255, 255)</td>
</tr>
<tr style="background-color: mintcream;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">MintCream</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#F5FFFA</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(245, 255, 250)</td>
</tr>
<tr style="background-color: snow;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">Snow</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#FFFAFA</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(255, 250, 250)</td>
</tr>
<tr style="background-color: ivory;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">Ivory</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#FFFFF0</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(255, 255, 240)</td>
</tr>
<tr style="background-color: white;">
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle;">White</td>
<td style="width: 31.329%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#FFFFFF</td>
<td style="width: 37.4853%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(255, 255, 255)</td>
</tr>
</tbody>
</table></div>
<p>&nbsp;</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr style="height: 67.6071px;">
<th style="border-style: solid; border-width: 2px; vertical-align: middle; text-align: left; width: 100.138%; height: 67.6071px;" colspan="3">
<h3 id="black-gray-color-names-with-codes" style="text-align: center;">Black &amp; gray color names with codes</h3>
</th>
</tr>
<tr style="height: 23.7976px;">
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Color name</th>
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Hex color code</th>
<th style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">RGB decimal code</th>
</tr>
<tr style="background-color: black; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;" width="64"><span style="color: #ecf0f1;">Black</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;" width="64"><span style="color: #ecf0f1;">#000000</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;" width="110"><span style="color: #ecf0f1;">(&nbsp;0, &nbsp;&nbsp;0, &nbsp;&nbsp;0)</span></td>
</tr>
<tr style="background-color: darkslategray; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #ecf0f1;">DarkSlateGray</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">#2F4F4F</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">(&nbsp;47, &nbsp;79, &nbsp;79)</span></td>
</tr>
<tr style="background-color: dimgray; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #ecf0f1;">DimGray</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">#696969</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">(105, 105, 105)</span></td>
</tr>
<tr style="background-color: slategray; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #ecf0f1;">SlateGray</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">#708090</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">(112, 128, 144)</span></td>
</tr>
<tr style="background-color: gray; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #ecf0f1;">Gray</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">#808080</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">(128, 128, 128)</span></td>
</tr>
<tr style="background-color: lightslategray; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #ecf0f1;">LightSlateGray</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">#778899</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">(119, 136, 153)</span></td>
</tr>
<tr style="background-color: darkgray; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;">DarkGray</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#A9A9A9</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(169, 169, 169)</td>
</tr>
<tr style="background-color: silver; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;">Silver</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#C0C0C0</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(192, 192, 192)</td>
</tr>
<tr style="background-color: lightgray; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;">LightGray</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#D3D3D3</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(211, 211, 211)</td>
</tr>
<tr style="background-color: gainsboro; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;">Gainsboro</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#DCDCDC</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(220, 220, 220)</td>
</tr>
</tbody>
</table></div>
<p>&nbsp;</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr style="height: 67.6071px;">
<th style="border-style: solid; border-width: 2px; vertical-align: middle; text-align: left; width: 100.138%; height: 67.6071px;" colspan="3">
<h3 id="red-color-names-with-codes" style="text-align: center;">Red color names with codes</h3>
</th>
</tr>
<tr style="height: 23.7976px;">
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Color name</th>
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Hex color code</th>
<th style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">RGB decimal code</th>
</tr>
<tr style="background-color: darkred; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;" width="74"><span style="color: #ecf0f1;">DarkRed</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;" width="77"><span style="color: #ecf0f1;">#8B0000</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;" width="91"><span style="color: #ecf0f1;">(139, &nbsp;&nbsp;0, &nbsp;&nbsp;0)</span></td>
</tr>
<tr style="background-color: red; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">Red</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#FF0000</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(255, &nbsp;&nbsp;0, &nbsp;&nbsp;0)</span></td>
</tr>
<tr style="background-color: firebrick; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">Firebrick</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#B22222</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(178, &nbsp;34, &nbsp;34)</span></td>
</tr>
<tr style="background-color: crimson; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">Crimson</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#DC143C</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(220, &nbsp;20, &nbsp;60)</span></td>
</tr>
<tr style="background-color: indianred; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">IndianRed</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#CD5C5C</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(205, &nbsp;92, &nbsp;92)</span></td>
</tr>
<tr style="background-color: lightcoral; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;">LightCoral</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#F08080</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(240, 128, 128)</td>
</tr>
<tr style="background-color: salmon; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;">Salmon</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#FA8072</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(250, 128, 114)</td>
</tr>
<tr style="background-color: darksalmon; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;">DarkSalmon</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#E9967A</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(233, 150, 122)</td>
</tr>
<tr style="background-color: lightsalmon; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">LightSalmon</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#FFA07A</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(255, 160, 122)</td>
</tr>
</tbody>
</table></div>
<p>&nbsp;</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr style="height: 67.6071px;">
<th style="border-style: solid; border-width: 2px; vertical-align: middle; text-align: left; width: 100.138%; height: 67.6071px;" colspan="3">
<h3 id="green-color-names-with-codes" style="text-align: center;">Green color names with codes</h3>
</th>
</tr>
<tr style="height: 23.7976px;">
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Color name</th>
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Hex color code</th>
<th style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">RGB decimal code</th>
</tr>
<tr style="background-color: darkgreen; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;" width="106"><span style="color: #ecf0f1;">DarkGreen</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;" width="89"><span style="color: #ecf0f1;">#006400</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;" width="130"><span style="color: #ecf0f1;">( 0, 100, &nbsp;&nbsp;0)</span></td>
</tr>
<tr style="background-color: green; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">Green</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#008000</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">( 0, 128, &nbsp;&nbsp;0)</span></td>
</tr>
<tr style="background-color: darkolivegreen; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">DarkOliveGreen</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#556B2F</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(&nbsp;85, 107, &nbsp;47)</span></td>
</tr>
<tr style="background-color: forestgreen; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">ForestGreen</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#228B22</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(&nbsp;34, 139, &nbsp;34)</span></td>
</tr>
<tr style="background-color: seagreen; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">SeaGreen</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#2E8B57</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(&nbsp;46, 139, &nbsp;87)</span></td>
</tr>
<tr style="background-color: olive; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">Olive</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#808000</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(128, 128, &nbsp;&nbsp;0)</span></td>
</tr>
<tr style="background-color: olivedrab; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">OliveDrab</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#6B8E23</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(107, 142, &nbsp;35)</span></td>
</tr>
<tr style="background-color: mediumseagreen; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">MediumSeaGreen</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#3CB371</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(&nbsp;60, 179, 113)</span></td>
</tr>
<tr style="background-color: limegreen; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">LimeGreen</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#32CD32</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(&nbsp;50, 205, &nbsp;50)</span></td>
</tr>
<tr style="background-color: lime; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;">Lime</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#00FF00</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">( 0, 255, &nbsp;&nbsp;0)</td>
</tr>
<tr style="height: 23.7976px; background-color: springgreen;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;">SpringGreen</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#00FF7F</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">( 0, 255, 127)</td>
</tr>
<tr style="height: 23.7976px; background-color: mediumspringgreen;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;">MediumSpringGreen</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#00FA9A</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">( 0, 250, 154)</td>
</tr>
<tr style="height: 23.7976px; background-color: darkseagreen;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;">DarkSeaGreen</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#8FBC8F</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(143, 188, 143)</td>
</tr>
<tr style="height: 23.7976px; background-color: mediumaquamarine;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;">MediumAquamarine</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#66CDAA</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(102, 205, 170)</td>
</tr>
<tr style="height: 23.7976px; background-color: yellowgreen;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;">YellowGreen</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#9ACD32</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(154, 205, &nbsp;50)</td>
</tr>
<tr style="height: 23.7976px; background-color: lawngreen;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;">LawnGreen</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#7CFC00</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(124, 252, &nbsp;&nbsp;0)</td>
</tr>
<tr style="height: 23.7976px; background-color: chartreuse;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;">Chartreuse</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#7FFF00</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(127, 255, &nbsp;&nbsp;0)</td>
</tr>
<tr style="height: 23.7976px; background-color: lightgreen;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;">LightGreen</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#90EE90</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(144, 238, 144)</td>
</tr>
<tr style="height: 23.7976px; background-color: greenyellow;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;">GreenYellow</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#ADFF2F</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(173, 255, &nbsp;47)</td>
</tr>
<tr style="height: 23.7976px; background-color: palegreen;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle;">PaleGreen</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#98FB98</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(152, 251, 152)</td>
</tr>
</tbody>
</table></div>
<p>&nbsp;</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr style="height: 67.6071px;">
<th style="border-style: solid; border-width: 2px; vertical-align: middle; text-align: left; width: 100.138%; height: 67.6071px;" colspan="3">
<h3 id="blue-color-names-with-codes" style="text-align: center;">Blue color names with codes</h3>
</th>
</tr>
<tr style="height: 23.7976px;">
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Color name</th>
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Hex color code</th>
<th style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">RGB decimal code</th>
</tr>
<tr style="background-color: navy; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;" width="64"><span style="color: #ecf0f1;">Navy</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;" width="64"><span style="color: #ecf0f1;">#000080</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;" width="84"><span style="color: #ecf0f1;">( 0, &nbsp;&nbsp;0, 128)</span></td>
</tr>
<tr style="background-color: darkblue; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #ecf0f1;">DarkBlue</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">#00008B</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">( 0, &nbsp;&nbsp;0, 139)</span></td>
</tr>
<tr style="background-color: mediumblue; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #ecf0f1;">MediumBlue</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">#0000CD</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">( 0, &nbsp;&nbsp;0, 205)</span></td>
</tr>
<tr style="background-color: blue; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #ecf0f1;">Blue</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">#0000FF</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">( 0, &nbsp;&nbsp;0, 255)</span></td>
</tr>
<tr style="background-color: midnightblue; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #ecf0f1;">MidnightBlue</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">#191970</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">(&nbsp;25, &nbsp;25, 112)</span></td>
</tr>
<tr style="background-color: royalblue; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #ecf0f1;">RoyalBlue</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">#4169E1</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">(&nbsp;65, 105, 225)</span></td>
</tr>
<tr style="background-color: steelblue; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #000000;">SteelBlue</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #000000;">#4682B4</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #000000;">(&nbsp;70, 130, 180)</span></td>
</tr>
<tr style="background-color: dodgerblue; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #000000;">DodgerBlue</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #000000;">#1E90FF</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #000000;">(&nbsp;30, 144, 255)</span></td>
</tr>
<tr style="background-color: deepskyblue; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #000000;">DeepSkyBlue</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #000000;">#00BFFF</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #000000;">( 0, 191, 255)</span></td>
</tr>
<tr style="background-color: cornflowerblue; height: 23.7976px;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;"><span style="color: #000000;">CornflowerBlue</span></td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #000000;">#6495ED</span></td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #000000;">(100, 149, 237)</span></td>
</tr>
<tr style="height: 23.7976px; background-color: skyblue;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;">SkyBlue</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#87CEEB</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(135, 206, 235)</td>
</tr>
<tr style="height: 23.7976px; background-color: lightskyblue;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;">LightSkyBlue</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#87CEFA</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(135, 206, 250)</td>
</tr>
<tr style="height: 23.7976px; background-color: lightsteelblue;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;">LightSteelBlue</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#B0C4DE</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(176, 196, 222)</td>
</tr>
<tr style="height: 23.7976px; background-color: lightblue;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;">LightBlue</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#ADD8E6</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(173, 216, 230)</td>
</tr>
<tr style="height: 23.7976px; background-color: powderblue;">
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px;">PowderBlue</td>
<td style="width: 31.3275%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#B0E0E6</td>
<td style="width: 37.4835%; height: 23.7976px; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(176, 224, 230)</td>
</tr>
</tbody>
</table></div>
<p>&nbsp;</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr style="height: 67.6071px;">
<th style="border-style: solid; border-width: 2px; vertical-align: middle; text-align: left; width: 100.138%; height: 67.6071px;" colspan="3">
<h3 id="purple-related-color-names-with-codes" style="text-align: center;">Purple related color names with codes</h3>
</th>
</tr>
<tr style="height: 23.7976px;">
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Color name</th>
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Hex color code</th>
<th style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">RGB decimal code</th>
</tr>
<tr style="background-color: indigo; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;" width="64"><span style="color: #ecf0f1;">Indigo</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;" width="64"><span style="color: #ecf0f1;">#4B0082</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;" width="89"><span style="color: #ecf0f1;">(&nbsp;75, &nbsp;&nbsp;0, 130)</span></td>
</tr>
<tr style="background-color: purple; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">Purple</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#800080</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(128, &nbsp;&nbsp;0, 128)</span></td>
</tr>
<tr style="background-color: rebeccapurple;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">Rebeccapurple</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#663399</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(102, 51, 153)</span></td>
</tr>
<tr style="background-color: darkmagenta; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">DarkMagenta</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ecf0f1;">#8B008B</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(139, &nbsp;&nbsp;0, 139)</span></td>
</tr>
<tr style="background-color: darkviolet; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">DarkViolet</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#9400D3</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(148, &nbsp;&nbsp;0, 211)</span></td>
</tr>
<tr style="background-color: darkslateblue; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">DarkSlateBlue</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#483D8B</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(&nbsp;72, &nbsp;61, 139)</span></td>
</tr>
<tr style="background-color: blueviolet; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">BlueViolet</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#8A2BE2</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(138, &nbsp;43, 226)</span></td>
</tr>
<tr style="background-color: darkorchid; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">DarkOrchid</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#9932CC</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(153, &nbsp;50, 204)</span></td>
</tr>
<tr style="background-color: fuchsia; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">Fuchsia</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#FF00FF</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(255, &nbsp;&nbsp;0, 255)</span></td>
</tr>
<tr style="background-color: magenta; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">Magenta</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#FF00FF</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(255, &nbsp;&nbsp;0, 255)</span></td>
</tr>
<tr style="background-color: slateblue; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">SlateBlue</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#6A5ACD</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(106, &nbsp;90, 205)</span></td>
</tr>
<tr style="background-color: mediumslateblue;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">MediumSlateBlue</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#7B68EE</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(123, 104, 238)</span></td>
</tr>
<tr style="background-color: mediumorchid;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">MediumOrchid</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#BA55D3</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(186, &nbsp;85, 211)</span></td>
</tr>
<tr style="background-color: mediumpurple;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;"><span style="color: #ecf0f1;">MediumPurple</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">#9370DB</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;"><span style="color: #ecf0f1;">(147, 112, 219)</span></td>
</tr>
<tr style="background-color: orchid;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;">Orchid</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#DA70D6</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(218, 112, 214)</td>
</tr>
<tr style="background-color: violet;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;">Violet</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#EE82EE</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(238, 130, 238)</td>
</tr>
<tr style="background-color: plum;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;">Plum</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#DDA0DD</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(221, 160, 221)</td>
</tr>
<tr style="background-color: thistle;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;">Thistle</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#D8BFD8</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(216, 191, 216)</td>
</tr>
<tr style="background-color: lavender;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle;">Lavender</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">#E6E6FA</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center;">(230, 230, 250)</td>
</tr>
</tbody>
</table></div>
<p>&nbsp;</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr style="height: 67.6071px;">
<th style="border-style: solid; border-width: 2px; vertical-align: middle; text-align: left; width: 100.138%; height: 67.6071px;" colspan="3">
<h3 id="pink-color-names-with-codes" style="text-align: center;">Pink color names with codes</h3>
</th>
</tr>
<tr style="height: 23.7976px;">
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Color name</th>
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Hex color code</th>
<th style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">RGB decimal code</th>
</tr>
<tr style="background-color: mediumvioletred; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;" width="64"><span style="color: #ecf0f1;">MediumVioletRed</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;" width="64"><span style="color: #ecf0f1;">#C71585</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;" width="98"><span style="color: #ecf0f1;">(199, &nbsp;21, 133)</span></td>
</tr>
<tr style="background-color: deeppink; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">DeepPink</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FF1493</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(255, &nbsp;20, 147)</td>
</tr>
<tr style="background-color: palevioletred; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">PaleVioletRed</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#DB7093</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(219, 112, 147)</td>
</tr>
<tr style="background-color: hotpink; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">HotPink</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FF69B4</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(255, 105, 180)</td>
</tr>
<tr style="background-color: lightpink; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">LightPink</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FFB6C1</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(255, 182, 193)</td>
</tr>
<tr style="background-color: pink; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Pink</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FFC0CB</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(255, 192, 203)</td>
</tr>
</tbody>
</table></div>
<p>&nbsp;</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr style="height: 67.6071px;">
<th style="border-style: solid; border-width: 2px; vertical-align: middle; text-align: left; width: 100.138%; height: 67.6071px;" colspan="3">
<h3 id="orange-color-names-with-codes" style="text-align: center;">Orange color names with codes</h3>
</th>
</tr>
<tr style="height: 23.7976px;">
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Color name</th>
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Hex color code</th>
<th style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">RGB decimal code</th>
</tr>
<tr style="background-color: orangered; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;" width="64"><span style="color: #ffffff;">OrangeRed</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;" width="64"><span style="color: #ffffff;">#FF4500</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;" width="93"><span style="color: #ffffff;">(255, &nbsp;69, &nbsp;&nbsp;0)</span></td>
</tr>
<tr style="background-color: tomato; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">Tomato</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">#FF6347</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">(255, &nbsp;99, &nbsp;71)</span></td>
</tr>
<tr style="background-color: darkorange; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">DarkOrange</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">#FF8C00</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">(255, 140, &nbsp;&nbsp;0)</span></td>
</tr>
<tr style="background-color: coral; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">Coral</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">#FF7F50</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">(255, 127, &nbsp;80)</span></td>
</tr>
<tr style="background-color: orange; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">Orange</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">#FFA500</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">(255, 165, &nbsp;&nbsp;0)</span></td>
</tr>
</tbody>
</table></div>
<p>&nbsp;</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr style="height: 67.6071px;">
<th style="border-style: solid; border-width: 2px; vertical-align: middle; text-align: left; width: 100.138%; height: 67.6071px;" colspan="3">
<h3 id="cyan-color-names-with-codes" style="text-align: center;">Cyan color names with codes</h3>
</th>
</tr>
<tr style="height: 23.7976px;">
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Color name</th>
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Hex color code</th>
<th style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">RGB decimal code</th>
</tr>
<tr style="background-color: teal; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;" width="64"><span style="color: #ffffff;">Teal</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;" width="64"><span style="color: #ffffff;">#008080</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;" width="125"><span style="color: #ffffff;">( 0, 128, 128)</span></td>
</tr>
<tr style="background-color: darkcyan; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">DarkCyan</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">#008B8B</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">( 0, 139, 139)</span></td>
</tr>
<tr style="background-color: lightseagreen; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">LightSeaGreen</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">#20B2AA</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">(&nbsp;32, 178, 170)</span></td>
</tr>
<tr style="background-color: cadetblue; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">CadetBlue</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">#5F9EA0</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">(&nbsp;95, 158, 160)</span></td>
</tr>
<tr style="background-color: darkturquoise; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">DarkTurquoise</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">#00CED1</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;"><span style="color: #ffffff;">( 0, 206, 209)</span></td>
</tr>
<tr style="background-color: mediumturquoise;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">MediumTurquoise</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#48D1CC</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(&nbsp;72, 209, 204)</td>
</tr>
<tr style="background-color: turquoise;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Turquoise</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#40E0D0</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(&nbsp;64, 224, 208)</td>
</tr>
<tr style="background-color: aqua;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Aqua</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#00FFFF</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">( 0, 255, 255)</td>
</tr>
<tr style="background-color: cyan;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Cyan</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#00FFFF</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">( 0, 255, 255)</td>
</tr>
<tr style="background-color: aquamarine;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Aquamarine</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#7FFFD4</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(127, 255, 212)</td>
</tr>
<tr style="background-color: paleturquoise;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">PaleTurquoise</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#AFEEEE</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(175, 238, 238)</td>
</tr>
<tr style="background-color: lightcyan;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">LightCyan</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#E0FFFF</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(224, 255, 255)</td>
</tr>
</tbody>
</table></div>
<p>&nbsp;</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr style="height: 67.6071px;">
<th style="border-style: solid; border-width: 2px; vertical-align: middle; text-align: left; width: 100.138%; height: 67.6071px;" colspan="3">
<h3 id="yellow-color-names-with-codes" style="text-align: center;">Yellow color names with codes</h3>
</th>
</tr>
<tr style="height: 23.7976px;">
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Color name</th>
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Hex color code</th>
<th style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">RGB decimal code</th>
</tr>
<tr style="background-color: darkkhaki; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;" width="64"><span style="color: #000000;">DarkKhaki</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;" width="64"><span style="color: #000000;">#BDB76B</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;" width="132"><span style="color: #000000;">(189, 183, 107)</span></td>
</tr>
<tr style="background-color: gold; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Gold</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FFD700</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(255, 215, &nbsp;&nbsp;0)</td>
</tr>
<tr style="background-color: khaki; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Khaki</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#F0E68C</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(240, 230, 140)</td>
</tr>
<tr style="background-color: peachpuff; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">PeachPuff</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FFDAB9</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(255, 218, 185)</td>
</tr>
<tr style="background-color: yellow; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Yellow</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FFFF00</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(255, 255, &nbsp;&nbsp;0)</td>
</tr>
<tr style="background-color: palegoldenrod;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">PaleGoldenrod</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#EEE8AA</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(238, 232, 170)</td>
</tr>
<tr style="background-color: moccasin;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Moccasin</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FFE4B5</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(255, 228, 181)</td>
</tr>
<tr style="background-color: papayawhip;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">PapayaWhip</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FFEFD5</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(255, 239, 213)</td>
</tr>
<tr style="background-color: lightgoldenrodyellow;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">LightGoldenrodYellow</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FAFAD2</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(250, 250, 210)</td>
</tr>
<tr style="background-color: lemonchiffon;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">LemonChiffon</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FFFACD</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(255, 250, 205)</td>
</tr>
<tr style="background-color: lightyellow;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">LightYellow</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center;">#FFFFE0</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center;">(255, 255, 224)</td>
</tr>
</tbody>
</table></div>
<p>&nbsp;</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr style="height: 67.6071px;">
<th style="border-style: solid; border-width: 2px; vertical-align: middle; text-align: left; width: 100.138%; height: 67.6071px;" colspan="3">
<h3 id="brown-color-names-with-codes" style="text-align: center;">Brown color names with codes</h3>
</th>
</tr>
<tr style="height: 23.7976px;">
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Color name</th>
<th style="width: 31.3275%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">Hex color code</th>
<th style="width: 37.4835%; border-style: solid; border-width: 2px; vertical-align: middle; text-align: center; height: 23.7976px;">RGB decimal code</th>
</tr>
<tr style="background-color: maroon; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;" width="78"><span style="color: #ffffff;">Maroon</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;" width="92"><span style="color: #ffffff;">#800000</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;" width="130"><span style="color: #ffffff;">(128, &nbsp;&nbsp;0, &nbsp;&nbsp;0)</span></td>
</tr>
<tr style="background-color: brown; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">Brown</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">#A52A2A</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">(165, &nbsp;42, &nbsp;42)</span></td>
</tr>
<tr style="background-color: saddlebrown; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">SaddleBrown</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">#8B4513</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">(139, &nbsp;69, &nbsp;19)</span></td>
</tr>
<tr style="background-color: sienna; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">Sienna</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">#A0522D</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">(160, &nbsp;82, &nbsp;45)</span></td>
</tr>
<tr style="background-color: chocolate; height: 23.7976px;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">Chocolate</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">#D2691E</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">(210, 105, &nbsp;30)</span></td>
</tr>
<tr style="background-color: darkgoldenrod;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">DarkGoldenrod</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">#B8860B</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">(184, 134, &nbsp;11)</span></td>
</tr>
<tr style="background-color: peru;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;"><span style="color: #ffffff;">Peru</span></td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">#CD853F</span></td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;"><span style="color: #ffffff;">(205, 133, &nbsp;63)</span></td>
</tr>
<tr style="background-color: rosybrown;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">RosyBrown</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#BC8F8F</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(188, 143, 143)</td>
</tr>
<tr style="background-color: goldenrod;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Goldenrod</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#DAA520</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(218, 165, &nbsp;32)</td>
</tr>
<tr style="background-color: sandybrown;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">SandyBrown</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#F4A460</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(244, 164, &nbsp;96)</td>
</tr>
<tr style="background-color: tan;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Tan</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#D2B48C</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(210, 180, 140)</td>
</tr>
<tr style="background-color: burlywood;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Burlywood</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#DEB887</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(222, 184, 135)</td>
</tr>
<tr style="background-color: wheat;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Wheat</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#F5DEB3</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(245, 222, 179)</td>
</tr>
<tr style="background-color: navajowhite;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">NavajoWhite</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#FFDEAD</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(255, 222, 173)</td>
</tr>
<tr style="background-color: bisque;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Bisque</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#FFE4C4</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(255, 228, 196)</td>
</tr>
<tr style="background-color: blanchedalmond;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">BlanchedAlmond</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#FFEBCD</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(255, 235, 205)</td>
</tr>
<tr style="background-color: cornsilk;">
<td style="width: 31.3275%; border-style: solid; border-width: 2px;">Cornsilk</td>
<td style="width: 31.3275%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">#FFF8DC</td>
<td style="width: 37.4835%; border-style: solid; border-width: 2px; text-align: center; vertical-align: middle;">(255, 248, 220)</td>
</tr>
</tbody>
</table></div>
<p>The above colors are sorted as per their shades or tints and the aim of this article is to make you aware of all the different color names that exist and which can be used directly without worrying to look after their hex color codes or RGB color codes.</p>
<p>Often people try finding the color codes for commonly used colors viz., blue, navy blue, light blue, royal blue, sky blue, dark blue, gold, silver etc, but these color names can be directly used without the need of their hex codes in almost all editors or color manipulation tools.&nbsp;</p>
<p>Even in design tools like <strong>Figma</strong> one can directly use the above all color names. It's just that there shouldn't be any space between the color names.</p>
<p>A few useful color names which you can remember are lightgray, lightslategray, royalblue, lightskyblue, whitesmoke, snow, cornflowerblue, aliceblue etc.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Chrome extension to convert text to image instantly]]></title>
            <link>https://devapt.com/text-image-extension</link>
            <guid isPermaLink="false">https://devapt.com/text-image-extension</guid>
            <pubDate>Thu, 21 Apr 2022 09:45:03 GMT</pubDate>
            <description><![CDATA[Here is a way to convert text to image just by selecting the text. You can copy or download the image easily. There are beautiful backgrounds to select.]]></description>
            <content:encoded><![CDATA[<p>There are various types of browser extensions that help to accomplish certain tasks very easily.&nbsp;</p>
<p>We have already seen one such interesting <a href="https://devapt.com/copy-text-easily-chrome-extension" target="_blank" rel="noopener">chrome extension to copy text</a> easily as never before just with a click.&nbsp;</p>
<p>Here is one more such unique chrome extension that helps to <a href="https://devapt.com/text-image-extension">convert text to image</a> just instantly.</p>
<p>Let's see how this text to image extension works and how we can make the best use of it while browsing the web.</p>
<h2 id="generate-image-from-text-selection" style="text-align: center;">Generate image from text selection</h2>
<p>Before going to use this extension you need to first install it from the chrome store. You can get this from the below link.&nbsp;</p>
<p>➜ <a href="https://chrome.google.com/webstore/detail/text-to-image/nkljaohokglebeljcgchmehnhdieakda" target="_blank" rel="noopener">Text to image chrome extension</a></p>
<p>Once you installed this extension you can find it in the extensions bar and if you can't find it, check it in the dropdown menu of extensions and pin to find it in the main extensions bar.&nbsp;</p>
<p>In order to use it just visit any website where you can be able to select text or just use this website.</p>
<p>Select any text you want and then right-click to see the <em>Text to image</em> option in the right-click menu or specifically the context menu and from there click copy or download.&nbsp;</p>
<p>That's it you'll have the image of the text that you selected, voila!</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1650609298/devapt/Text-to-image-chrome-extension.gif" alt="Text-to-image-chrome-extension" width="700" height="350" /></p>
<h3 id="how-to-customize-the-generated-image">How to customize the generated image?</h3>
<p>You can customize the look of the image that is generated from the selected text with the help of the options available.&nbsp;</p>
<p>When you click the extension icon you can see three customization options viz., mode, padding, and color palettes.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1650609306/devapt/Text-to-image-menu.webp" alt="Text-to-image-extension-options" width="453" height="300" /></p>
<h4>1. Mode&nbsp;</h4>
<p>With the help of the mode option, you can select the light or dark mode for the card that holds the text.&nbsp;</p>
<p>By default, it is in light mode.&nbsp;</p>
<h4>2. Padding</h4>
<p>The padding refers to the spacing around the text card which helps us to see the background. You have various values to pick from 0px to 128px.</p>
<p>When you select the 0px(pixels) it will hide the background and all the space will be occupied by the text card.</p>
<p>When you do not want any fancy background, instead just plain text with a white/dark background, you can make the padding 0px.&nbsp;</p>
<h4>3. Color palette</h4>
<p>From the color palette, you can pick your favorite color backgrounds to show behind the text card.&nbsp;</p>
<p>These color backgrounds are mostly the gradient colors which make these text images appear nice and attention grabbing.&nbsp;</p>
<p>Note that when you select 0px padding, these background colors will be hidden as there won't be any space.&nbsp;</p>
<h4>4. Download&nbsp;</h4>
<p>To quickly download the image just after selecting the text you can use this option for downloading the generated image to your device.&nbsp;</p>
<p>There are shortcuts for copying and downloading the image.</p>
<p><strong>Shortcut to copy:</strong> <kbd>Ctrl+Shift+Z</kbd></p>
<p><strong>Shortcut to download:</strong> <kbd>Ctrl+Shift+&darr;</kbd>(down arrow)</p>
<p>Sometimes these shortcuts may conflict with the shortcuts in the browser or some websites. So keep this in mind while trying them out.</p>
<p>Right-click context menu options are always there whenever you face such issues.&nbsp;</p>
<h3 id="where-to-use-text-to-image-extension">Where to use text to image extension?</h3>
<p>If you know why this extension was created, and the main problem it wants to address then it would give an idea of where to use this extension effectively.&nbsp;</p>
<p>There was a situation where I wanted to reply to tweets on Twitter with more than 280 characters, it was difficult or a bit cumbersome to tweet multiple times.&nbsp;</p>
<p>At that time I thought if there was something that could help me instantly to send messages that are of more than 280 characters without leaving the browser.</p>
<p>Then an idea struck me to convert the text to an image instantly which then can be shared as a reply to tweets.&nbsp;</p>
<p>And as a result, this <strong><em>text to image</em></strong> extension is born.</p>
<p>So this extension can be used to share long texts as replies/tweets on Twitter. You can also save text info from websites as images for your future reference.&nbsp;</p>
<p>Sometimes when you want to show text in a fancy and attractive manner you can use it there as well.&nbsp;</p>
<p>If you want to create more rich text effects including images, code snippets, etc you can try out this full-fledged solution from <a href="https://tweetlet.net/" target="_blank" rel="noopener">tweetlet</a> website that helps you create amazing and visually appealing images.&nbsp;</p>
<p>If you want a demo of this extension you can watch this video.&nbsp;</p>
<div class="flex justify-center"><iframe class=" rounded-xl overflow-hidden" title="Text to image chrome extension intro" src="https://www.youtube-nocookie.com/embed/ybaH7ts4xtQ?rel=0" width="680" height="350" frameborder="0" allowfullscreen="allowfullscreen"></iframe></div>
<p>That's it about this interesting tool that helps you to convert any selected text instantly to an image without leaving your browser.</p>
<p>Please feel free to share any suggestions/feedback/improvements in this tool.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Create beautiful images from tweets, text and other images]]></title>
            <link>https://devapt.com/create-images-tweetlet</link>
            <guid isPermaLink="false">https://devapt.com/create-images-tweetlet</guid>
            <pubDate>Mon, 14 Mar 2022 08:45:45 GMT</pubDate>
            <description><![CDATA[Here is the way to create beautiful images from your tweets, text and any other image just in a snap. This helps to share long text as images easily.]]></description>
            <content:encoded><![CDATA[<p>In this social media era, information gets shared in various forms. Text, image, and video are the quite commonly used media formats on the internet.</p>
<p>Images are the commonly used format for displaying information in an attractive way. Images are easy to save and share info.&nbsp;</p>
<p>Images and videos are also the preferred media formats for getting good engagement for your posts on social media.&nbsp;</p>
<p>It's a good idea to convert text to images that are attractive and informative, which is nothing but called infographics.&nbsp;</p>
<p>Here is a tool using which you can convert text, tweet, or any other image into a beautiful image with an attractive background to share on different social media platforms.</p>
<p>The tool is called <a href="https://tweetlet.net/" target="_blank" rel="noopener">tweetlet </a>and the images generated by it are called tweetlets.&nbsp;</p>
<p>Let's learn more about this tweetlet tool to make cool photos out of it.</p>
<h2 id="create-beautiful-images-using-tweetlet" style="text-align: center;">Create beautiful images using tweetlet</h2>
<p>Tweetlet.net site has three different modes for creating images:</p>
<ol>
<li>Tweet to image</li>
<li>Image to a beautiful image with background</li>
<li>Text to image</li>
</ol>
<p>To switch to a particular mode, just hover/click on the icon in the search bar, and using that you can switch to a tweet or image, or text mode.</p>
<p>The image can be resized with the help of the white clips provided on the edge of the image. Dragging by holding those resizers(white clips) will resize the image.&nbsp;</p>
<p>In every mode, there are two buttons for copying and downloading the image. Besides that, you can select the desired background from the preset gradients and adjust the image to a ready-made aspect ratio of 1:1 or 2:1.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1647282518/devapt/Tweetlet.webp" alt="Tweetlet-create-images-from-tweets" width="720" height="296" /></p>
<h3 id="1-tweet-to-image">1. Tweet to image</h3>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1647282616/devapt/Tweetlet-tweet-mode.webp" alt="Tweet-to-image-tweetlet" width="720" height="331" /></p>
<p>To convert any <a href="https://tweetlet.net/tweet" target="_blank" rel="noopener">tweet to an image</a> just copy the tweet's link and paste it into the search box of the tweetlet website.&nbsp;</p>
<p>It will create a beautiful quote-like image by default. With the help of controls, you can change it to a tweet mode from quote to make it appear exactly like the actual tweet.</p>
<p>With the help of controls, you can also adjust the size of the text, toggle the likes and shares of a tweet, change the background with various preset gradients.&nbsp;</p>
<p>Finally, when you are satisfied with the image, click copy or download it.&nbsp;</p>
<h3 id="2-image-to-a-beautiful-image-with-a-background">2. Image to a beautiful image with a background</h3>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1647282723/devapt/Tweetlet-image-mode.webp" alt="Image-to-beautiful-background-tweetlet" width="720" height="448" /></p>
<p>In the <a href="https://tweetlet.net/image" target="_blank" rel="noopener">image mode of tweetlet</a>, you can upload or paste any image directly in the tweetlet site and it will appear with a cool background.</p>
<p>You can resize the image with the help of the resizers.&nbsp;</p>
<p>A cool trick to create a stack-effect image is to copy the current image and paste it and repeat until the stack level you want.</p>
<p>You can change the background as per your interest and finally copy or download the image to share it on any platform you want.</p>
<h3 id="3-text-to-image">3. Text to image</h3>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1647282766/devapt/Tweetlet-text-mode.webp" alt="Text-to-image-tweetlet" width="720" height="365" /></p>
<p>This is the most powerful way to convert various kinds of text into a beautiful image.&nbsp;</p>
<p>First, switch to the <a href="https://tweetlet.net/text" target="_blank" rel="noopener">text mode</a> and you'll see a text box with a resizer at the bottom, dragging which you can resize the height of the text box.&nbsp;</p>
<p>This text box supports markdown text. That means you can have rich text effects using this.&nbsp;</p>
<p>Syntax for the rich text as follows:</p>
<p># Heading 1 =&gt; <span style="font-size: 18pt;">Heading 1</span></p>
<p>## Heading 2 =&gt;&nbsp; <span style="font-size: 16pt;">Heading 2</span></p>
<p>### Heading 3 =&gt; <span style="font-size: 14pt;">Heading 3</span></p>
<p>*italics* or _italics_ =&gt; <em>italics</em></p>
<p>**bold** or __bold__ =&gt; <strong>bold</strong></p>
<p>`inline code` =&gt; <code>inline code</code></p>
<p><strong>For code blocks:</strong><br />```js<br />console.log('Hi');<br />````</p>
<p>Mentioning the correct language will enable to highlight the code as per that language, else it will show just a plain pre-formatted text.&nbsp;</p>
<p>Using the markdown syntax, you can even embed other images along with your text to create beautiful images using all of it.</p>
<p>You can learn more about the markdown syntax <a href="https://www.markdownguide.org/basic-syntax/" target="_blank" rel="noopener">here</a>.</p>
<p>Text mode will be useful for sharing code snippets and rich text info easily as an image.</p>
<p>If you want to create images instantly just by selecting the text you can check this <a href="https://chrome.google.com/webstore/detail/text-to-image/nkljaohokglebeljcgchmehnhdieakda" target="_blank" rel="noopener">text to image</a> chrome extension that generates images from selected text in the blink of the eye.</p>
<p>As usual, once you are satisfied with all the adjustments, you can copy or download the image to share it on any platform you wanted.&nbsp;</p>
<p>There's a dark mode icon at the top right corner where you can switch to the dark mode or light mode based on your preference. Your gradient and mode settings will be stored locally so whenever you open the site your previous settings get reflected.&nbsp;</p>
<p>You can directly try out all the above-mentioned modes from <a href="https://tweetlet.net/" target="_blank" rel="noopener">tweetlet.net</a> right away. And if you want any new features you can send a message/feedback from the message icon present at the bottom right corner.&nbsp;</p>
<p>Last but not the least, if you like this tweetlet tool, then do share it with your friends.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[What is YAML? Learn YAML syntax & yaml vs json differences]]></title>
            <link>https://devapt.com/yaml-vs-json</link>
            <guid isPermaLink="false">https://devapt.com/yaml-vs-json</guid>
            <pubDate>Mon, 28 Feb 2022 08:45:19 GMT</pubDate>
            <description><![CDATA[YAML is a human-readable serialization language similar to XML and JSON. Here are all you need to know about the YAML syntax and comparisons with JSON]]></description>
            <content:encoded><![CDATA[<p>YAML is a recursive acronym for <em>Yaml ain't markup language</em>. It is generally considered easier to read than more verbose XML or JSON serialization languages.</p>
<blockquote>
<p><strong>Serialization</strong> is the process of translating a data structure or object state into a format that can be stored or transmitted and reconstructed later.</p>
</blockquote>
<p><code>YAML</code> is most often used for configuration files of servers and software applications. YAML files have an extension of .yaml or .yml. <a href="https://yaml.org/faq.html" target="_blank" rel="noopener">Yaml official site</a> recommends using <code>.yaml</code> extension whenever possible.</p>
<p>YAML syntax has python like indentation with nesting for representing hierarchical data. YAML is a superset of JSON, so every JSON data is a valid YAML but not vice-versa.</p>
<p>A sample YAML file looks like below.</p>
<pre class="language-yaml"><code>---
name: John
age: 25
hobbies:
  - swimming
  - dancing
  - programming</code></pre>
<p>YAML is used for config files in <a href="https://devapt.com/dynamodb-nodejs-crud" target="_blank" rel="noopener">AWS</a>, Docker, etc.</p>
<h2 id="yaml-syntax" style="text-align: center;">YAML syntax</h2>
<h3 id="comments">Comments</h3>
<p>Unlike JSON, YAML allows having comments in the file. These comments can be inserted using a number sign(<code>#</code>). &nbsp;If <code>#</code> characters appear inside a string, then they are considered number sign <code>#</code>&nbsp;literals.</p>
<pre class="language-yaml"><code># This is a comment in yaml
name: John</code></pre>
<h3 id="strings-and-numbers">Strings and numbers</h3>
<p>YAML supports various kinds of data types strings, numbers, boolean, arrays or lists, etc. The key-value pairs are separated with a colon followed by a space.</p>
<pre class="language-yaml"><code># Object(key-value pairs)
project: XYZ
version: 2.0</code></pre>
<p>It's optional to wrap strings with single or double-quotes. If there are any special characters or punctuation marks like colon(<code>:</code>) or dashes(<code>-</code>) in the strings then wrapping with quotes is recommended.</p>
<p>Tab characters are not allowed in YAML only whitespaces have to be used for indentation.&nbsp;</p>
<h3 id="booleans">Booleans</h3>
<p>The allowed boolean values are <code>true/false</code>, <code>yes/no</code>, <code>on/off</code></p>
<pre class="language-yaml"><code># Boolean value property
isOpenSource: true # equivalents &rarr; yes or on</code></pre>
<h3 id="nesting-key-value-pairs">Nesting key-value pairs</h3>
<p>The nesting of the key-value pairs is done by indenting the key-value pairs in the next line after the colon.</p>
<pre class="language-yaml"><code># Nested object(key-value pairs)
details:
  name: Server config
  service: abc
  state: started</code></pre>
<h3 id="arrays-or-lists">Arrays or lists</h3>
<p>An array sequence starts with a dash(<code>-</code>) followed by a space and the indentation separates from the parent.&nbsp;</p>
<pre class="language-yaml"><code># Array of values
technologies:
  - SQL
  - GO
  - Javascript</code></pre>
<p>An array of objects(key-value pairs) can be written similarly just by indenting each key-value pair in reference to the dash(<code>-</code>).</p>
<pre class="language-yaml"><code># Array of objects
collaborators:
  - name: John
    age: 25
  - name: James
    age: 26</code></pre>
<h3 id="multiline-strings">Multiline strings</h3>
<p>A pipe(<code>|</code>) character at the beginning of the string is used to have a string with multi-lines preserved without having to use any escape characters.</p>
<pre class="language-yaml"><code># Multiline strings
summary: |
  This is the first line of the string.
  This is the second and line break is preserved.</code></pre>
<p>When a greater than character(<code>&gt;</code>) is used at the beginning of the string then the multi-lines get wrapped by stripping leading indentations and trailing white spaces. This is good for writing the readable lines of strings without the need to preserve the line breaks.</p>
<pre class="language-yaml"><code># Folded text
description: &gt;
  This is a very very long text just wrapped
  in multi-lines but all this text is considered
  as a continuous text without any line breaks.</code></pre>
<h3 id="document-separator">Document separator</h3>
<p>YAML allows having multiple documents in a single file by separating them with three hyphens(<code>---</code>).</p>
<pre class="language-yaml"><code>---
# A yaml document
project: XYZ</code></pre>
<h2 id="yaml-vs-json" style="text-align: center;">YAML vs JSON</h2>
<p>The main aim of YAML is to make the data easily readable and understandable. Some of the major differences between YAML and JSON are:</p>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; border-style: solid;" border="1">
<tbody>
<tr style="height: 23.7976px;">
<th style="width: 48.0477%; text-align: center; height: 23.7976px; border-style: solid; border-width: 2px;">YAML</th>
<th style="width: 48.0477%; text-align: center; height: 23.7976px; border-style: solid; border-width: 2px;">JSON</th>
</tr>
<tr style="height: 23.7976px;">
<td style="width: 48.0477%; vertical-align: top; text-align: left; height: 23.7976px; border-style: solid; border-width: 2px;">1. Easy to read and understand</td>
<td style="width: 48.0477%; vertical-align: top; text-align: left; height: 23.7976px; border-style: solid; border-width: 2px;">1. A bit difficult to read and understand</td>
</tr>
<tr style="height: 23.7976px;">
<td style="width: 48.0477%; vertical-align: top; text-align: left; height: 23.7976px; border-style: solid; border-width: 2px;">2. Uses nested indentation for hierarchy</td>
<td style="width: 48.0477%; vertical-align: top; text-align: left; height: 23.7976px; border-style: solid; border-width: 2px;">2. Uses braces and brackets for hierarchy</td>
</tr>
<tr style="height: 23.7976px;">
<td style="width: 48.0477%; vertical-align: top; text-align: left; height: 23.7976px; border-style: solid; border-width: 2px;">3. Comments are allowed</td>
<td style="width: 48.0477%; vertical-align: top; text-align: left; height: 23.7976px; border-style: solid; border-width: 2px;">3. No comments are allowed</td>
</tr>
<tr style="height: 23.7976px;">
<td style="width: 48.0477%; vertical-align: top; text-align: left; height: 23.7976px; border-style: solid; border-width: 2px;">4. Wrapping strings with quotes is optional</td>
<td style="width: 48.0477%; vertical-align: top; text-align: left; height: 23.7976px; border-style: solid; border-width: 2px;">4. Must wrap strings with double quotes</td>
</tr>
<tr style="height: 47.5952px;">
<td style="width: 48.0477%; vertical-align: top; text-align: left; height: 47.5952px; border-style: solid; border-width: 2px;">5. Multiple documents are allowed in a single file</td>
<td style="vertical-align: top; text-align: left; height: 47.5952px; border-style: solid; border-width: 2px;">5. Only one document per file</td>
</tr>
<tr style="height: 23.7976px;">
<td style="width: 48.0477%; vertical-align: top; text-align: left; height: 23.7976px; border-style: solid; border-width: 2px;">6. It's a superset of JSON</td>
<td style="width: 48.0477%; vertical-align: top; text-align: left; height: 23.7976px; border-style: solid; border-width: 2px;">6. Every JSON is a valid YAML</td>
</tr>
<tr style="height: 23.7976px;">
<td style="width: 48.0477%; vertical-align: top; height: 23.7976px; border-style: solid; border-width: 2px;">7. Mostly used for configuration files</td>
<td style="width: 48.0477%; vertical-align: top; height: 23.7976px; border-style: solid; border-width: 2px;">7. Mostly used for transmitting data</td>
</tr>
<tr>
<td style="width: 48.0477%; vertical-align: top; border-style: solid; border-width: 2px;">8. Python developers like this format</td>
<td style="width: 48.0477%; vertical-align: top; border-style: solid; border-width: 2px;">8. Javascript developers like this format</td>
</tr>
</tbody>
</table></div>
<p>Below is the similar kind of data represented in YAML and JSON formats.</p>
<h3 id="a-typical-yaml-file">A typical YAML file</h3>
<pre class="language-yaml"><code>--- # YAML example
project: XYZ
version: 2.0
isOpenSource: true
technologies:
  - SQL
  - GO
  - Javascript
collaborators:
  - name: John
    age: 25
  - name: James
    age: 26
details:
  name: Server config
  service: abc
  state: started
summary: |
  This is the first line of the string.
  This is the second and line break is preserved.
description: &gt;
  This is a very very long text just wrapped
  in multi-lines but all this text is considered
  as a continuous text without any line breaks.</code></pre>
<h3 id="the-equivalent-json-file">The equivalent JSON file&nbsp;</h3>
<pre class="language-json"><code>{
    "project": "XYZ",
    "version": 2,
    "isOpenSource": true,
    "technologies": [
        "SQL",
        "GO",
        "Javascript"
    ],
    "collaborators": [
        {
            "name": "John",
            "age": 25
        },
        {
            "name": "James",
            "age": 26
        }
    ],
    "details": {
        "name": "Server config",
        "service": "abc",
        "state": "started"
    },
    "summary": "This is the first line of the string.\nThis is the second and line break is preserved.\n",
    "description": "This is a very very long text just wrapped in multi-lines but all this text is considered as a continuous text without any line breaks\n"
}</code></pre>
<p>YAML also has a few more features like node anchors, references etc.&nbsp; But all the above-discussed features are the essential ones to know in YAML. There are YAML linting tools to validate the YAML files which you can use to validate your files.</p>
<p>That's all about YAML and its comparison with JSON.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[10 JavaScript tips and tricks that makes you a better dev]]></title>
            <link>https://devapt.com/javascript-tips-tricks</link>
            <guid isPermaLink="false">https://devapt.com/javascript-tips-tricks</guid>
            <pubDate>Mon, 21 Feb 2022 08:45:04 GMT</pubDate>
            <description><![CDATA[Here are some of the best JavaScript tips and tricks that you should know. These tips can help you to develop Javascript applications with ease.]]></description>
            <content:encoded><![CDATA[<p>JavaScript has become the most popular language in the last few years. It is also the language that powers the web along with HTML and CSS.&nbsp;</p>
<p>JavaScript has evolved in such a manner that almost any kind of application for any platform can be created using it through its huge collection of libraries and frameworks available as open source.&nbsp;</p>
<blockquote>
<p style="text-align: right;"><em>Any application that can be written in JavaScript, will eventually be written in JavaScript.</em></p>
<p style="text-align: right;">- Jeff Atwood</p>
</blockquote>
<p>JavaScript has its pros and cons along with its quirks. Most people are using it for the pros it offers in solving problems or creating applications.</p>
<p>A problem can be solved in different ways using JavaScript. In this article, we are going to look at some of the best JavaScript tips to write simple and efficient JS code.&nbsp;</p>
<h2 id="10-javascript-tips-and-tricks" style="text-align: center;">10 JavaScript tips and tricks</h2>
<h3 id="1-sorting-in-javascript">1. Sorting in javascript</h3>
<p>The <code>sorting()</code> array method in JS is a mutating method which means it modifies the order of the elements of the original array.</p>
<p>A better approach is to duplicate the array and sort it.</p>
<p>Sorting in JavaScript is by default lexicographic, so for sorting numbers, it's always essential to sort by a callback function.&nbsp;</p>
<pre class="language-javascript"><code>// Sorting directly
const arr = [4, 20, 10, 1, 3, 5];
arr.sort(); // arr: [1, 10, 20, 3, 4, 5]</code></pre>
<pre class="language-javascript"><code>// Sorting by duplicating the array
const arr = [4, 20, 10, 1, 3, 5];
const sortedArr = arr.slice().sort((a, b) =&gt; a - b);

// arr: [4, 20, 10, 1, 3, 5]
// sortedArr: [1, 3, 4, 5, 10, 20]</code></pre>
<h3 id="2-flattening-array-in-javascript">2. Flattening array in JavaScript</h3>
<p>Flattening an array means putting all the elements of nested arrays into the main array.&nbsp;</p>
<p>There are quite <a href="https://devapt.com/javascript-flatten-array" target="_blank" rel="noopener">different ways to flatten arrays in JavaScript</a>. There's a <code>flat()</code> method added in ES10 or Ecmascript version 2019 to flatten the array directly.&nbsp;</p>
<p><code>flat()</code> method takes an argument as the max. depth that has to be flattened to. The default depth is 1.&nbsp;</p>
<p>To flatten the array of any depth use <code>Infinity</code> as the argument.</p>
<pre class="language-javascript"><code>const letters = ['a', 'b', ['c', 'd', ['e', 'f']]];
const flatArray = letters.flat(2); // Flatten until depth 2

// flatArray: ['a', 'b', 'c', 'd', 'e', 'f'];</code></pre>
<h3 id="3-shuffle-array-in-javascript">3. Shuffle array in JavaScript</h3>
<p>To shuffle an array we can use <code>sort()</code> method by returning a random positive or negative number in the callback.</p>
<p>We can generate random positive or negative number using</p>
<pre class="language-javascript"><code>// Random positive and negative number
Math.random() - 0.5</code></pre>
<pre class="language-javascript"><code>const letters = ['a', 'b', 'c', 'd', 'e', 'f'];
const shuffledArray = [...letters].sort(() =&gt; Math.random() - 0.5);

// shuffledArray: ["e", "d", "b", "a", "f", "c"]
// shuffledArray: ["b", "d", "f", "a", "c", "e"]</code></pre>
<h3 id="4-filter-falsy-values">4. Filter falsy values</h3>
<p>There are six falsy values in JavaScript. They are 0, <code>''</code>, null, undefined, false, NaN.</p>
<p>We can easily filter out those values using the <code>Boolean</code> global function.</p>
<pre class="language-javascript"><code>const arr = [1, 0, 2, '', 3, null, 4];
const filtered = arr.filter(Boolean); 

// filtered: [1, 2, 3, 4]</code></pre>
<h3 id="5-object-destructuring">5. Object destructuring</h3>
<p>Object destructuring is a very useful technic to extract values from an object in the desired variables.&nbsp;</p>
<p>We can rename the keys using <code>:</code>(colon) and also assign default values using <code>=</code> if a certain destructured variable doesn't exist in the object.</p>
<p>We can also assign the object values to an already declared variable by wrapping the destructured code in parenthesis.</p>
<pre class="language-javascript"><code>const person = {
  name: 'John',
  years: 25,
  occupation: 'developer',
};

let occupation;

const { name, years: age, place = 'remote' } = person;
({ occupation } = person);

// name: John
// age: 25
// place: remote
// occupation: developer</code></pre>
<h3 id="6-sleep-or-delay-in-javascript">6. Sleep or delay in JavaScript</h3>
<p>JavaScript executes code synchronously. There's no built-in function in JS to sleep or delay synchronous code.&nbsp;</p>
<p>We can create a sleep function with the help of a promise.</p>
<pre class="language-javascript"><code>// Sleep function using promise
const sleep = (ms) =&gt; new Promise((resolve) =&gt; setTimeout(resolve, ms));</code></pre>
<pre class="language-javascript"><code>const sleep = (ms) =&gt; new Promise((resolve) =&gt; setTimeout(resolve, ms));

async function print() {
  console.log('First line ');
  await sleep(2000); // sleeps for 2 seconds
  console.log('Second line');
}

print();
// First line
// ...after 2 seconds
// Second line</code></pre>
<h3 id="7-typecast-strings-to-numbers">7. Typecast strings to numbers</h3>
<p>When you have an array of string numbers and type casting those to numbers can be done easily using the global <code>Number</code> function.</p>
<pre class="language-javascript"><code>const strings = ['1', '2', '3', '4' , '5'];
const numbers = strings.map(Number);

// strings: ['1', '2', '3', '4' , '5']
// numbers: [1, 2, 3, 4, 5]</code></pre>
<h3 id="8-operators">8. !!, ~~, + operators</h3>
<h4>Convert any value to boolean using !!</h4>
<p><code>!</code> is a bitwise not operator. Using <code>!!</code> we can quickly convert any value to a boolean.</p>
<pre class="language-javascript"><code>const isPresent = 'yes';

!!isPresent; // true</code></pre>
<h4>Trim the decimal part using ~~</h4>
<p>We can use <code>~~</code> to quickly trim the decimal part of a number. This can be used as an alternative to <code>Math.floor()</code>.</p>
<p>In JavaScript <code>~number = -(number + 1)</code></p>
<pre class="language-javascript"><code>const price = 25.4;
~~price; // 25</code></pre>
<h4>Typecast string to a number using +</h4>
<p>We can prefix <code>+</code> to string numbers to quickly convert them to number type.</p>
<pre class="language-javascript"><code>const rate = '15';
const amount = +rate;

// rate: '15'
// amount: 15</code></pre>
<h3 id="9-nullish-coalescing-and-optional-chaining">9. Nullish coalescing (??) and optional chaining (?.)</h3>
<p><code>??</code> nullish coalescing operator is used to handle <code>null</code> or <code>undefined</code> values.&nbsp;</p>
<p>Whenever <code>null</code> or <code>undefined</code> value is encountered we can return a default value.</p>
<p>This doesn't work for other boolean values like 0, NaN, <code>''</code>, false. To handle all boolean values we can use <code>||</code> logical OR.</p>
<pre class="language-javascript"><code>let visitor;
let person;

visitor = 'Doe';
person =  visitor ?? 'staff';
// person: Doe

visitor = null;
person =  visitor ?? 'staff';
// person: staff</code></pre>
<p>Optional chaining is used to avoid throwing of error whenever there's a missing key in an object.</p>
<pre class="language-javascript"><code>const person = {
  name: 'John',
  books: null
}
person.books.name // throws error

person.books?.name // returns undefined</code></pre>
<h3 id="10-remove-the-duplicates-in-an-array">10. Remove the duplicates in an array</h3>
<p>Removing duplicates could be cumbersome sometimes. But using the <code>Set()</code> this can be achieved in simple steps.</p>
<p>A Set is a collection of unique data types in Javascript. Learn about <a href="https://devapt.com/javascript-set-weakset" target="_blank" rel="noopener">Javascript set</a> here.</p>
<pre class="language-javascript"><code>const letters = ['a', 'b', 'c', 'b', 'a', 'd']; // duplicates
const uniqueLetters = [...new Set(letters)]; 

// uniqueLetters: ['a', 'b', 'c', 'd']</code></pre>
<p>That's all in this article. These are some of the interesting JavaScript tips to know about. We'll see more tips in the upcoming articles.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Chrome extension to copy text in the simplest possible way]]></title>
            <link>https://devapt.com/copy-text-easily-chrome-extension</link>
            <guid isPermaLink="false">https://devapt.com/copy-text-easily-chrome-extension</guid>
            <pubDate>Mon, 14 Feb 2022 08:44:46 GMT</pubDate>
            <description><![CDATA[A simple chrome extension that can help you to copy text easily in various modes with just one click. It has three different modes to copy text.]]></description>
            <content:encoded><![CDATA[<p>We often copy text or code snippets or any other kind of resource quite commonly while browsing the web. Copying sometimes got to be tedious work in certain situations.</p>
<p>Using keyboard shortcuts quite often for various tasks is found to be a great time-saver in the long run. But certain people who are not much used to a keyboard, like using the mouse for all their small to big activities in the browser.</p>
<p>Copying and pasting text with the shortcuts <code>Ctrl + C</code> and <code>Ctrl + V </code>&nbsp;are the world's highly used shortcuts and these shortcuts are known almost to all the people who use a computer.</p>
<blockquote>
<p>Do you remember yourself copying text with <code>Ctrl + C C C C C C C</code>, typing C multiple times to make sure the text gets copied?</p>
</blockquote>
<p>Sometimes we tend to put a bit more time even with copy shortcuts. When you want to copy text just so frequently, let's say you want to shift a formatted text from one place to the other and that can be copied only as paragraphs and not as a whole, in such situations, copying and pasting text with even shortcuts is going to be a very tedious job. Not just this case but in any case that involves frequent copying and pasting text gets tedious even with shortcuts.</p>
<p>So keeping in mind various contexts involved in copying text, a small and compact chrome extension is made to <em><a href="https://devapt.com/copy-text-easily" target="_blank" rel="noopener">Copy Text Easily</a><strong>.</strong></em></p>
<p>Using Copy Text Easily(CTE)&nbsp;extension effectively has the potential to save a lot of time in the long run for those who involve in copying text just so frequently. e.g., Students copying reference details to their journals, etc.</p>
<p>Let's see all the features that this Copy Text Easily extension provides.</p>
<h2 id="copy-text-easily-extension" style="text-align: center;">Copy Text Easily extension</h2>
<p>Before getting started to use this Copy Text Extension, you need to first install it from the chrome store. You can install the extension from this link <a title="Copy Text Easily Extension link" href="https://chrome.google.com/webstore/detail/copy-text-easily/fagmaopcbeobbfhkeodicjekiniefdlo" target="_blank" rel="noopener">Copy Text Easily Extension</a>.</p>
<h4>CTE chrome extension has got three modes for copying text</h4>
<ol>
<li>Paragraph(default)</li>
<li>Sentence</li>
<li>Custom</li>
</ol>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1641718402/devapt/Copy-Text-Easily-chrome-extension.jpg" alt="Copy-Text-Easily-options" width="222" height="266" /></p>
<h3 id="1-paragraph-mode">1. Paragraph mode:</h3>
<p>In paragraph mode, you can copy the blocks of text by hovering on any block of text you want. A small preview of the text that you are going to copy will be displayed for convenience. Just clicking on the block of text will get the text copied.&nbsp;</p>
<p>This mode is very useful for copying blocks of code or code snippets on StackOverflow, GitHub, etc.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1641720032/devapt/stackoverflow-copy-text-easily.gif" alt="Copy-Text-Easily-Paragraph-mode" width="670" height="359" /></p>
<h3 id="2-sentence-mode">2. Sentence mode:</h3>
<p>This is a very unique way to copy sentences from a paragraph. By hovering the mouse on and off the paragraph, you can see different sentences getting selected to copy the text. Whichever sentence you want can be seen in the preview box and just clicking once will get that particular sentence copied to your clipboard.&nbsp;</p>
<p>This mode is very useful while working with sentences related to writing works.&nbsp;</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1641719595/devapt/sentence-short.gif" alt="Copy-Text-Easily-Extension-sentence-mode" width="670" height="325" /></p>
<h3 id="3-custom-mode">3. Custom mode:</h3>
<p>This is the customized mode to copy any text you want just by selecting. Yes, just selecting a text will copy the text to the clipboard. This is useful in situations when you can want to copy a very specific text when it is not possible with the above previous modes.&nbsp;</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1641720291/devapt/custom-short.gif" alt="Copy-Text-Easily-Custom-mode" width="670" height="325" /></p>
<p>By default, the extension will be active on the active browser tab, and the mouse hovering will result in the preview of text hovered. So to avoid that there's an option to activate this extension on demand by pressing any of <code>Ctrl</code>, <code>Alt</code>, <code>Shift</code> keys. You can select the key at your convenience from the extension keypress options.&nbsp;</p>
<p>There's even an option to enable or disable the whole extension and the keypress mode.&nbsp;</p>
<p>Coming to privacy, this extension fully runs on your browser locally and doesn't communicate with the outside world. It is packed in under 15KB of pure JavaScript code without any libraries or frameworks.&nbsp;</p>
<p><strong>If you face any problems with this extension you can try the below methods:</strong></p>
<ol>
<li>Reload the page whichever is having a problem</li>
<li>Check if the extension is enabled</li>
<li>Check if you have enabled the extension to work only on keypress</li>
<li>Sometimes 'Shift' and 'Alt' keys might have problems, so try to select the 'Ctrl' key if you have problems</li>
</ol>
<p>And that is all about this simple chrome extension to copy the text in a hassle-free manner.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Google tricks that make you pro at googling anything]]></title>
            <link>https://devapt.com/google-tricks-tips</link>
            <guid isPermaLink="false">https://devapt.com/google-tricks-tips</guid>
            <pubDate>Tue, 08 Feb 2022 08:45:35 GMT</pubDate>
            <description><![CDATA[Here are the Google tricks that help to use Google in the most effective manner. Knowing to google effectively is a great time-saving skill.]]></description>
            <content:encoded><![CDATA[<p>In this internet era finding and searching information is simplified by search engines. One such well-known and sophisticated search engine is Google.&nbsp;</p>
<p>Google has become an integral part of internet users. It is the most highly used search engine around the world accounting for 5-7 billion searches every day as of 2022.&nbsp;</p>
<p>Google is so often used that it was added to the English language as a standard word for searching using Google search engine. So google, googled, googling, etc are the standard English words now.&nbsp;</p>
<p>As already said, it is a sophisticated search engine, using it we can find or search almost any kind of information in this world.&nbsp;</p>
<p>Using Google to quickly find what we want is sometimes considered a skill. Yes, it is a kind of skill to find any information just in a few seconds.&nbsp;</p>
<p>Anybody can master this skill by following a few simple tips and tricks. In this article, we are going to look at some of the essential Google tricks that can help you to quickly search and filter any kind of information you wanted using Google.&nbsp;</p>
<p>Note: The sample or example search queries will be indicated after the magnifying glass.&nbsp;</p>
<h2 id="google-tricks-to-google-like-a-pro" style="text-align: center;">Google tricks to google like a pro</h2>
<h3 id="1-search-tricks-to-find-the-exact-info">1. Search tricks to find the exact info</h3>
<h4>Search for an exact match:</h4>
<p>To find the search results containing the exact keywords of your search, put your keywords inside quotes(<strong>" "</strong>).&nbsp;</p>
<p>For example, if you want to find results for your exact keywords, say <span style="text-decoration: underline;">rare flowers</span>. Search as below.</p>
<ul style="list-style: '🔎';">
<li>"rare flowers"</li>
</ul>
<h4>Search for keywords in title, URL and text:</h4>
<p>To search for results containing keywords in the specific parts of the results, you should use</p>
<ul>
<li><strong>intitle:</strong> to look for keywords in the title</li>
<li><strong>inurl:</strong> to look for the keywords in the URL</li>
<li><strong>intext:</strong> to look for the keywords in the text</li>
</ul>
<p><em>Don't give any spacing after the colon(:).</em></p>
<ul style="list-style: '🔎';">
<li>intitle:rare flowers</li>
<li>inurl:rare flowers</li>
<li>intext:rare flowers</li>
</ul>
<h4>Search for specific file types:</h4>
<p>You can find search results containing specific file types using <strong>filetype:</strong> flag. Using this you can look for various file types like <code>pdf</code>,&nbsp; <code>.ps</code>,&nbsp;<code>.xls</code>,&nbsp;<code>.ppt</code>,&nbsp;<code>.doc</code> etc</p>
<p>You can put this <em>filetype:</em> flag before or after search keywords. It's better to use after the search keywords because it helps to differentiate the search keywords with the flag.</p>
<ul style="list-style: '🔎';">
<li>web development filetype:pdf&nbsp;</li>
</ul>
<h4>Search within a site:</h4>
<p>You can find results for your keywords within a specific site using <strong>site:</strong> flag. You can also use this <em>site:</em> flag to see the links that are indexed by Google.</p>
<ul style="list-style: '🔎';">
<li>edge tips site:devapt.com</li>
</ul>
<h4>Search for related sites:</h4>
<p>You can use <strong>related:</strong> flag for finding the sites that are related to the given site. This is helpful for finding the alternative or related sites of a site.</p>
<ul style="list-style: '🔎';">
<li>related:twitter.com</li>
</ul>
<h4>Search for Google's cached version of a site:</h4>
<p>You can use <strong>cache:</strong> flag for checking Google's cached version of a site. It is mostly useful for the webmasters to check the cached version of sites.</p>
<ul style="list-style: '🔎';">
<li>cache:devapt.com</li>
</ul>
<h3 id="2-search-using-operators">2. Search using operators</h3>
<p>There are a few search operators that we can use in our search to quickly get the desired results.&nbsp;</p>
<p>A few operators are: #, @, $, -, .., *, OR, AND, :before, :after etc</p>
<h4>Search hashtags:</h4>
<p>Using <strong>#</strong> infront of keyword, searches for that particular hash-tagged posts from various social media sites.</p>
<ul style="list-style: '🔎';">
<li>#newyear</li>
</ul>
<h4>Search social media:</h4>
<p>Use <strong>@</strong> to search in a social media for the keywords.&nbsp;</p>
<ul style="list-style: '🔎';">
<li>rare flowers @twitter</li>
</ul>
<h4>Search for a particular price product:</h4>
<p>Use <strong>$</strong> infront of a number to search for that price.</p>
<ul style="list-style: '🔎';">
<li>mobile $100</li>
</ul>
<h4>Search within a range of numbers:</h4>
<p>Use <strong>..</strong> (two dots) to search within a range of numbers, which could be prices, years etc.&nbsp;</p>
<ul style="list-style: '🔎';">
<li>camera $300..$500</li>
</ul>
<h4>Search with optional keywords:</h4>
<p>Use <strong>*</strong> (asterisk) to search for something when you are not sure of certain keywords in your search.</p>
<ul style="list-style: '🔎';">
<li>learn * in a month</li>
</ul>
<h4>Search by excluding certain keywords:</h4>
<p>Use <strong>-</strong> (hypen or dash) to omit certain keyword results from your search results. This is useful to quickly filter out ambiguous results.</p>
<ul style="list-style: '🔎';">
<li>jaguar -car</li>
</ul>
<h4>Search one or more combinations:</h4>
<p>Use <strong>OR</strong> to combine search results for multiple keywords. Make sure that <em>OR</em> is in capital letters else it won't work.</p>
<ul style="list-style: '🔎';">
<li>new car OR bike</li>
</ul>
<h4>Search for common results:</h4>
<p>Use <strong>AND</strong> operator to get results that are common to both keywords. Make sure <em>AND</em> is in capital letters.</p>
<ul style="list-style: '🔎';">
<li>gps for car AND bike</li>
</ul>
<h4>Search by time:</h4>
<p>You can use <strong>before:</strong> or <strong>after:</strong> flags to search results before or after a particular time.</p>
<ul style="list-style: '🔎';">
<li>cryptocurrency before:2015</li>
<li>cryptocurrency after:2017</li>
</ul>
<h3 id="3-search-for-the-exact-image-size">3. Search for the exact image size</h3>
<p>This is one of the best google tricks ever you could find. Using <strong>imagesize:</strong> flag followed by <strong>widthxheight</strong> you can search for the exact size images using google.</p>
<p>This is highly useful for quickly finding the social media covers, profile pics, or website placeholder images of particular sizes etc.</p>
<p><em>Do not give any spaces in between the width and height.</em></p>
<ul style="list-style: '🔎';">
<li>rare flowers imagesize:1500x500</li>
</ul>
<h3 id="4-reverse-image-search">4. Reverse image search</h3>
<p>You can do a reverse image search that is, search using an image instead of keywords and find where it is all used or find similar type of images.</p>
<p>To search by image head over to <a href="https://images.google.com/" target="_blank" rel="noopener">images.google.com</a> and upload an image you want to find search results for.</p>
<h3 id="5-filter-search-results-using-tools-menu">5. Filter search results using <span style="text-decoration: underline;">Tools</span> menu</h3>
<p>When you do a google search, based on the type of search, <strong>Tools</strong> menu provides different filters using which you can filter out results selectively.&nbsp;</p>
<p>For instance when you do a text or all media search, you can see filter by time option using <em>Tools</em> menu.&nbsp;</p>
<p>But when you do a video search, that is you select the <strong>videos</strong> in the Google search menu bar, you can find various filters when you go to <strong>Tools </strong>menu. You will see filter by duration, time, quality, closed captions, video source etc.&nbsp;</p>
<p>Tools menu becomes so handy for filtering the search results directly without needing to use search flags or operators.&nbsp;</p>
<h3 id="6-open-search-results-in-a-new-tab">6. Open search results in a new tab</h3>
<p>Quite often people want to open search results in different tabs from Google SERP(Search Engine Results Page) without actually navigating back and forth.&nbsp;</p>
<p>Using <strong>Ctrl</strong> + Clicking the result will open the article/site in a new tab. But you can achieve this directly by updating your Google settings.</p>
<p>To open results in a new tab always:</p>
<ol>
<li>Go to <strong>Google's homepage</strong></li>
<li>Click <strong>Setting</strong> at the bottom right corner</li>
<li>Select <strong>Search settings</strong></li>
<li>Scroll down to find <strong>Where results open&nbsp;</strong>and check the box under it.</li>
<li>Scroll down to the bottom and click the <strong>Save</strong> button. That's it.</li>
</ol>
<p>And every time you click the result on the SERP, it will open in a new tab, voila!</p>
<h3 id="7-change-the-number-of-search-results-per-page">7. Change the number of search results per page</h3>
<p>By default 10 Google results are shown per page and the other results are paginated at the bottom.&nbsp;</p>
<p>If you are someone who wants to have more results per page, then you could do that by going to the Google settings from the homepage bottom right corner &gt; Search settings &gt; Search results &gt; Results per page.&nbsp;</p>
<p>Adjust the number of results you want per page, it would be multiples of 10 and then save the settings. That's it you'll see the set number of results per page every time you do a query on Google.</p>
<h3 id="8-enable-google-dark-mode">8. Enable google dark mode</h3>
<p>We all have seen and used Google in light mode for years. But you can enable the dark mode if you want.&nbsp;</p>
<p>To enable google dark theme go to settings from bottom right corner &gt; Search settings &gt; Appearance &gt; Select <strong>Dark theme&nbsp;</strong>and click save.</p>
<h3 id="9-funny-google-tricks">9. Funny google tricks</h3>
<p>There are a few funny tricks that gets activated when you type certain keywords in the Google's search box.</p>
<p>A few funny Google keywords are:</p>
<ul>
<li><a href="https://www.google.com/search?q=do+a+barrel+roll" target="_blank" rel="noopener">do a barrel roll</a> - this will roll the Google's search results page like a barrel</li>
<li><a href="https://www.google.com/search?q=askew" target="_blank" rel="noopener">askew</a> - this will tilt the search page like the Leaning Tower of Pisa</li>
<li><a href="https://www.google.com/search?q=anagram" target="_blank" rel="noopener">anagram</a> - this will show, if you mean to search for <strong>nag a ram</strong>, which is an anagram for anagram</li>
<li><a href="https://www.google.com/search?q=animal+sounds" target="_blank" rel="noopener">animal sounds</a> - this will show a list of animal sounds that you can hear directly from the SERP</li>
<li><a href="https://www.google.com/search?q=pacman" target="_blank" rel="noopener">pacman</a> - this will show the pacman game right in the results page where you can play it</li>
</ul>
<p>For more funny tricks you should see the Google's mirror site.</p>
<h3 id="10-google-mirror-site">10. Google mirror site</h3>
<p>There's a site with a domain name in the reverse order of the Google, called elgooG. This is an unofficial site claimed to be Google's mirror with some interesting and funny stuff.</p>
<p>The domain of the site is elgoog.im which means to say I'm elgooG.&nbsp;</p>
<p>There are so many easter eggs related to Google results page on this elgooG site.&nbsp;</p>
<p>You can visit this <a href="https://elgoog.im/" target="_blank" rel="noopener">elgoog</a> site and have fun with google gravity, thanos trick, google in 1998 etc all tricks.</p>
<p>That is all about the tricks to use Google smartly and effectively.</p>
<p>This article covers all the essential tricks that you ever need while searching on Google.&nbsp;</p>
<p>If you have any such interesting or useful trick, then do share it with us and we'll update it here.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Learn to flatten array in JavaScript with one liners]]></title>
            <link>https://devapt.com/javascript-flatten-array</link>
            <guid isPermaLink="false">https://devapt.com/javascript-flatten-array</guid>
            <pubDate>Mon, 31 Jan 2022 08:45:27 GMT</pubDate>
            <description><![CDATA[There are different ways to flatten arrays in JavaScript. Here are the 5 different ways to obtain flat arrays using one liners in JS.]]></description>
            <content:encoded><![CDATA[<p>In JavaScript, an array is a collection of ordered elements and there's no restriction for the type of elements.&nbsp;</p>
<blockquote>
<p>An array is said to be flat or flattened if there are no nested arrays inside the array.&nbsp;</p>
</blockquote>
<p>Let's see what an array and a flattened array look like with an example.</p>
<pre class="language-javascript"><code>// An array with nested arrays
const letters = ['a', 'b', ['c', 'd'], ['e', 'f']];

// Flattened array
["a", "b", "c", "d", "e", "f"]
</code></pre>
<p>In this article, we are going to see different ways to flatten arrays in JavaScript.&nbsp;</p>
<h2 id="flatten-arrays-in-js" style="text-align: center;">Flatten arrays in JS</h2>
<p>We'll see different ways to flatten this <code>letters</code> array in JS.&nbsp;</p>
<pre class="language-javascript"><code>const letters = ['a', 'b', ['c', 'd'], ['e', 'f']];</code></pre>
<h3 id="1-using-concat-array-method">1. Using concat() array method</h3>
<p><code>concat()</code> array method is used to merge two or more arrays. It takes a value or an array as an argument and concatenates it to the original array and returns the result as a new array without mutating the original one.</p>
<p>We'll use an empty array and concatenate the <code>letters</code> array elements with the help of a spread operator to spread the nested array elements.&nbsp;</p>
<pre class="language-javascript"><code>const letters = ['a', 'b', ['c', 'd'], ['e', 'f']];

const flatArray = [].concat(...letters);

// flatArray: ['a', 'b', 'c', 'd', 'e', 'f'];</code></pre>
<h3 id="2-using-concat-array-method-with-apply">2. Using concat() array method with apply()</h3>
<p>We can use <code>apply()</code> method on <code>concat</code> function as apply method helps to pass arguments in the form of an array which we have already seen in <a href="https://devapt.com/call-apply-bind-javascript" target="_blank" rel="noopener">call, apply, bind Javascript</a> article.</p>
<p>So the idea is to pass every individual element of the array to the <code>concate</code> method instead of the whole array.</p>
<p>In the previous method, we have used the <code>...</code> spread operator for the same reason.&nbsp;</p>
<pre class="language-javascript"><code>const letters = ['a', 'b', ['c', 'd'], ['e', 'f']];

const flatArray = [].concat.apply([], letters);

// flatArray: ['a', 'b', 'c', 'd', 'e', 'f'];</code></pre>
<p>The first array need not be empty and could be anything in <code>[].concat</code> because the array that we pass as the first argument to <code>apply()</code> will be considered for creating the new array.</p>
<h3 id="3-using-reduce-array-method">3. Using reduce() array method</h3>
<p>We can use <code>reduce()</code> method to flatten an array as flattening is a way of reducing the original array to a different form.</p>
<p>The idea is to spread every element and nested element in a new array and return the result, and the result is nothing but the flattened array.</p>
<pre class="language-javascript"><code>const letters = ['a', 'b', ['c', 'd'], ['e', 'f']];

const flatArray = letters.reduce((acc, curr) =&gt; [...acc, ...curr], []);

// flatArray: ['a', 'b', 'c', 'd', 'e', 'f'];</code></pre>
<p>We can omit the array given as a second argument to the <code>reduce</code> method, it is just to initialize the accumulator with an empty array.</p>
<h3 id="4-using-the-flat-array-method">4. Using the flat() array method</h3>
<p>There's a new array method called <code>flat()</code> added in the <a href="https://262.ecma-international.org/10.0/" target="_blank" rel="noopener">ECMAScript version 2019</a> or ES10. What it does is simply flattens the array when it is called.</p>
<p>Using <code>flat()</code> method we can flatten arrays of any depth by passing the max. depth to be flattened to as an argument to the flat method. The default depth is 1.</p>
<pre class="language-javascript"><code>const letters = ['a', 'b', ['c', 'd'], ['e', 'f']];

const flatArray = letters.flat(); // default depth 1

// flatArray: ['a', 'b', 'c', 'd', 'e', 'f'];</code></pre>
<p>To flatten an array of depth greater than 1.</p>
<pre class="language-javascript"><code>const letters = ['a', 'b', ['c', 'd', ['e', 'f']]];

const flatArray = letters.flat(2); // Flatten until depth 2

// flatArray: ['a', 'b', 'c', 'd', 'e', 'f'];</code></pre>
<p>To flatten any amount of depth, we can pass <code>Infinity</code> as the argument to the <code>flat()</code> method.</p>
<h3 id="5-by-converting-to-string-and-splitting">5. By converting to string and splitting</h3>
<p>Arrays of any depth when converted to a string gets flattened and will be joined by <code>,</code>(comma).</p>
<p>So using this technique after converting an array to a string and then splitting it by <code>,</code> we can flatten the array.</p>
<pre class="language-javascript"><code>const letters = ['a', 'b', ['c', 'd'], ['e', 'f']];

const flatArray = letters.toString().split(',');

// flatArray: ['a', 'b', 'c', 'd', 'e', 'f'];</code></pre>
<p>The main problem with this method is that it works well when all the elements in the array are strings or of any one specific type, say numbers. Because after generating the array we can convert it to a specific type.&nbsp;</p>
<p>But when the array consists of multiple type elements then it gets difficult to use this method.&nbsp;</p>
<p>Let's see how an array of numbers can be flattened using this technique.</p>
<pre class="language-javascript"><code>const numbers = [1, 2, [3, 4], [5, 6]];

const flatArray = numbers.toString().split(',').map(Number);
// or const flatArray = numbers.join().split(',').map(Number);
// or const flatArray = `${numbers}`.split(',').map(Number);

// flatArray: [1, 2, 3, 4, 5, 6]</code></pre>
<p>And that is all about different ways to flatten Javascript arrays. Most of the browsers have support for <code>flat()</code> method so it would be handy to use this method in most of the scenarios.</p>
<p>If you have any other way to flatten the arrays in a better manner then do share it with us and we'll be happy to update this article with that.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[10 amazing Microsoft Edge tips and tricks you should know]]></title>
            <link>https://devapt.com/microsoft-edge-tricks</link>
            <guid isPermaLink="false">https://devapt.com/microsoft-edge-tricks</guid>
            <pubDate>Wed, 26 Jan 2022 08:45:00 GMT</pubDate>
            <description><![CDATA[Microsoft Edge browser is based on chromium opensource project similar to the Google chrome. Here are some of the amazing features you should know in edge.]]></description>
            <content:encoded><![CDATA[<p>Microsoft Edge browser is a chromium-based browser, it is the same open-source software that Google Chrome uses.&nbsp;</p>
<p>Google Chrome has been the most popular browser since 2008 because of its performance, amazing features, and timely security updates. Until the last few years, there were no browsers that could match up with Chrome's performance.</p>
<p>But when Microsoft Edge became a chromium-based browser it started adding some of the coolest features in terms of performance and reliability. Now it is getting traction and has the true potential to overtake Google's chrome browser.&nbsp;</p>
<p>At present Edge has an edge in so many features compared to the chrome browser. In some instances, Edge is found to be faster than Chrome browser and it's no joke.&nbsp;</p>
<p>Once you start using the edge browser, you may never think of leaving it because of the experience and the features it provides.&nbsp;</p>
<p>There are some of the best features in the Edge browser that will make you fall in love with it.</p>
<p>Let's see all those amazing features of the Edge browser and then you decide how really amazing they are.&nbsp;</p>
<h2 id="10-amazing-microsoft-edge-tips-and-tricks" style="text-align: center;">10 amazing Microsoft Edge tips and tricks</h2>
<h3 id="1-generate-qr-codes">1. Generate QR codes</h3>
<p>With one click you can create a QR code of any website and download it.</p>
<p>Visit any site that you want to generate the QR code for and <em>right-click</em> somewhere on that site to see the context menu and select/click <em>Create QR code for this page&nbsp;</em>to generate the QR code.&nbsp;</p>
<p>You can also additionally click on the search box to see the QR code icon on the right side and clicking that icon will also generate the QR code for that webpage.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1643187918/devapt/qr-code-generator-edge.png" alt="QR-code-generator-edge-browser" width="450" height="238" /></p>
<h3 id="2-screen-read-text">2. Screen read text</h3>
<p>Edge has an inbuilt text reader with about 40+ voices including regional languages. This is an amazing feature to listen to the text on the news or highly text-based sites.&nbsp;</p>
<p>To activate reading mode just type ↪ <strong>Ctrl</strong> + <strong>Shift</strong> + <strong>U</strong> by visiting the page you want. Alternatively, you can select any particular text and <em>right-click</em> and then select <em>Read aloud</em>&nbsp;from the context menu to read it out.</p>
<p>You can also randomly listen to the text by clicking on it when the reading mode is on.</p>
<p>You can use the controls for starting or pausing the voice. By using the voice options you can switch to different voices and accents. You can also adjust the speed of the reader. Basically, it provides almost all the features of a stand-alone screen reader.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1643188190/devapt/screen-reader-edge-browser.png" alt="Screen-reader-edge-browser" width="613" height="312" /></p>
<h3 id="3-take-screenshots">3. Take screenshots</h3>
<p>Edge browser has an inbuilt screen capture tool using which you can quickly take a screenshot of a particular area or a full webpage.&nbsp;</p>
<p>To take a screenshot type ↪ <strong>Ctrl </strong>+ <strong>Shift</strong> + <strong>S</strong>, you will get two options to select, <em>Capture area</em> and <em>Capture full page&nbsp;</em>based on your selection you can take the screenshot.&nbsp;</p>
<p>Soon after capturing you can draw or doodle on the image quickly and save it or copy the image or even can share it directly with the share option. It got to be just so handy without having to use extensions or external applications for this.&nbsp;</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1643188585/devapt/screenshot-edge-browser.png" alt="Screenshot-edge-browser" width="613" height="312" /></p>
<h3 id="4-share-links-in-a-click">4. Share links in a click</h3>
<p>No more you have to copy the link and go to a particular social media or mailing application for sharing the links of the sites that do not have share buttons now.</p>
<p>With just one click you can share any website link with the social media applications you use. <em>Right-click</em> on the webpage and select/click the <em>share</em> option and then you'll be shown with the sites/apps to share the link with. That simple it is.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1643188944/devapt/sharing-links-edge-browser.png" alt="Sharing-links-edge-browser" width="473" height="293" /></p>
<h3 id="5-get-citation-details">5. Get citation details</h3>
<p>This is a highly useful feature for college students or researchers to cite the details of web pages for the research or journal papers.&nbsp;</p>
<p>Go to the more options by clicking the three dots or by pressing ↪ <strong>Alt</strong> + <strong>F</strong> and select <em>More tools&nbsp;</em>and from there click <em>Cite this&nbsp;</em>option.</p>
<p>You can get citations as per the IEEE, Harvard, and various other formats. You can enter author, title, DOI, publication date, volume, issue, etc all details related to the particular citation format and get it nicely formatted in just a few clicks.&nbsp;</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1643190070/devapt/citations-edge-browser.png" alt="Citation-detals-edge-browser" width="521" height="312" /></p>
<h3 id="6-solve-math-problems">6. Solve math problems</h3>
<p>The most amazing feature is this, you can solve various kinds of math problems just by scanning. It's an AI math solver inbuilt in the Edge browser.&nbsp;</p>
<p>You can solve any arithmetic, linear, quadratic, higher degree polynomial, matrix, and even complex numbers, etc problems just by scanning. It also shows steps involved in solving the problem.</p>
<p>This could be very handy for research students while reading papers to crosscheck the equations or problems listed.&nbsp;</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1643190586/devapt/math-solver-edge-browser.png" alt="Math-solver-edge-browser" width="521" height="312" /></p>
<h3 id="7-share-highlighted-text-of-a-site">7. Share highlighted text of a site</h3>
<p>Sharing a webpage link to highlight certain text or details is very easy now using the text highlighting feature.&nbsp;</p>
<p>Just select any text you want on a webpage and <em>right-click</em> and then select <em>Copy link to highlight</em> option from the context menu. That's it the link gets copied to your clipboard which you can share on any site or application.&nbsp;</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1643191018/devapt/copy-link-highlight-edge-browser.png" alt="Copy-highlighted-text-link-edge-browser" width="559" height="279" /></p>
<h3 id="8-immersive-reader">8. Immersive reader</h3>
<p>Edge has an immersive reading option to read text on websites without any distraction from ads and other content.&nbsp;</p>
<p>Immersive reader provides amazing learning and accessibility tools, such as Read aloud, Text preferences, Grammar tools, and more.&nbsp;</p>
<p>To enable immersive reader just click the speaker icon on the extreme right of the search bar. Sometimes it may not show up directly, for that just scroll down the page and reload the page to see that icon.</p>
<p><strong>Tip:</strong> When certain sites bug you to disable the ad blocker or don't allow you to read the text until subscribed, you can enable this immersive reader mode to bypass those and it works like a charm on most of the sites.&nbsp;</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1643191317/devapt/immersive-reader.png" alt="Immersive-reader-edge-browser" width="322" height="279" /></p>
<h3 id="9-save-sites-using-a-collection">9. Save sites using a collection</h3>
<p>Collections is a very nice feature that exists in the Edge browser. Using this you can quickly add your favorite web pages or sites to a collection. You can organize collections at your convenience. This is a cool and handy feature like bookmarking.&nbsp;</p>
<p>To add any site to your collections just <em>right-click</em> and select <em>Add page to collections</em> and then pick your collection to add to.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1643191742/devapt/collections-edge-browser.png" alt="Collections-edge-browser" width="481" height="312" /></p>
<h3 id="10-add-extensions-from-the-chrome-store">10. Add extensions from the chrome store</h3>
<p>You can add any extensions from the chrome store easily, and all work perfectly in the Edge browser. This could be highly useful when you want to maintain the same tools as in a chrome browser and have all your working extensions with you.</p>
<p>There are a few other very interesting features in the Edge browser like, you can enable edge bar for multi-tasking and browse webpages as a secondary tab, you can change the direction of your tabs from horizontal to vertical, and vice-versa, etc.&nbsp;</p>
<p>Let us know which of the above-listed features are really amazing to you. If you know any other features that are worth mentioning here do let us know through comments.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[10 HTML tags you have never used before]]></title>
            <link>https://devapt.com/html-tags</link>
            <guid isPermaLink="false">https://devapt.com/html-tags</guid>
            <pubDate>Fri, 21 Jan 2022 08:45:56 GMT</pubDate>
            <description><![CDATA[Here are the 10 HTML tags that you have never seen before. Learn when and how to use these tags in your project. Some of the tags are really handy...]]></description>
            <content:encoded><![CDATA[<p>HTML is a markup language that powers the web. In HTML5 so many things were added and improved. But there are certain HTML tags that are rarely used or are not known to many.&nbsp;</p>
<p>In this article, we're going to see 10 useful HTML tags that are seldom used by many people and these tags could be handy in certain situations.&nbsp;</p>
<h2 id="10-html-tags-to-know" style="text-align: center;">10 HTML tags to know</h2>
<h3 id="1-dialog-tag">1. dialog tag</h3>
<p>We can create a simple and good-looking dialog box with just one line of HTML code. Using <code>&lt;dialog&gt;</code> tag with <code>open</code> attribute, a nice centered dialog box can be created.&nbsp;</p>
<pre class="language-markup"><code>&lt;dialog open&gt;Hello world&lt;/dialog&gt;</code></pre>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1642781017/devapt/dialog-tag-html.jpg" alt="dialog-html-tag" width="400" height="62" /></p>
<p><code>&lt;dialog&gt;</code> tag supports all global and event attributes. We can use <code>dialog</code> box to notify users like an alert.&nbsp;</p>
<p><strong>Note:</strong> <em>Dialog tag has low support in Firefox and Safari browsers.&nbsp;</em></p>
<h3 id="2-progress-tag">2. progress tag</h3>
<p>A <code>&lt;progress&gt;</code> tag is used to indicate the progress of a task. This looks similar to the progress bars that we see while downloading files.&nbsp;</p>
<p><code>&lt;progress&gt;</code> tag has two attributes, <code>value</code> and <code>max</code>. The default value of <code>max</code> attribute is 1 and <code>value</code> attribute represents the fraction of the <code>max</code> value, nothing but progress.</p>
<pre class="language-markup"><code>&lt;label for="file"&gt;Download status&lt;/label&gt; &lt;br /&gt;
&lt;progress id="file" value="45" max="100"&gt;45%&lt;/progress&gt;</code></pre>
<p style="text-align: center;"><label for="file">Download status</label> <br /><progress id="file" value="45" max="100">45%</progress></p>
<p style="text-align: left;">In the above code snippet, when we make the value of <code>value</code> attribute to 0.45 and omit max, the result remains the same. We can use <code>label</code> tag to improve accessibility.&nbsp;</p>
<p style="text-align: left;"><code>&lt;progress&gt;</code> also supports all global and event attributes.&nbsp;</p>
<p style="text-align: left;">There's another tag similar to <code>&lt;progress&gt;</code> and we'll see it in the next section.</p>
<h3 id="3-meter-tag" style="text-align: left;">3. meter tag</h3>
<p><code>&lt;meter&gt;</code> tag is just similar to <code>&lt;progress&gt;</code> tag, but the meter tag is used to indicate the measurements or measuring units making it more semantical.&nbsp;</p>
<p><code>&lt;meter&gt;</code> tag has various attributes like <code>min</code>, <code>max</code>, <code>low</code>, <code>high</code>, <code>value</code> etc for indicating the progress bar.</p>
<pre class="language-markup"><code>&lt;!-- Indicating the pH level --&gt;
&lt;label for="ph"&gt;pH level&lt;/label&gt; &lt;br&gt;
&lt;meter id="ph" value="7" min="0" max="14"&gt;7&lt;/meter&gt;&lt;br&gt;</code></pre>
<p style="text-align: center;"><label for="ph">pH level</label> <br /><meter id="ph" value="7" min="0" max="14">7</meter></p>
<p><code>&lt;meter&gt;</code> tag also supports all global and event attributes.&nbsp;</p>
<h3 id="4-fieldset-tag">4. fieldset tag</h3>
<p><code>&lt;filedset&gt;</code> tag is generally used to group related items together in a form and it draws a nice border around those related items.&nbsp;</p>
<pre class="language-markup"><code>&lt;fieldset&gt;
  &lt;legend&gt;User details&lt;/legend&gt;
  &lt;label for="name"&gt;Name&lt;/label&gt;
  &lt;input type="text" id="name" name="name"&gt;&lt;br&gt;&lt;br&gt;
  &lt;label for="email"&gt;Email&lt;/label&gt;
  &lt;input type="email" id="email" name="email"&gt;&lt;br&gt;
&lt;/fieldset&gt;</code></pre>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1642784976/devapt/fieldset-html-tag.jpg" alt="fieldset-html-tag" width="500" height="110" /></p>
<p><code>&lt;legend&gt;</code> tag is used to give the display name to that fieldset border.</p>
<p><code>&lt;fieldset&gt;</code> tag has a <code>disabled</code> attribute for disabling the input elements inside the fieldset. It also supports all global and event attributes.</p>
<h3 id="5-datalist-tag">5. datalist tag</h3>
<p><code>&lt;datalist&gt;</code> tag is used to specify predefined options for an <code>input</code> element with autocomplete and dropdown features.&nbsp;</p>
<p><code>&lt;datalist&gt;</code> <code>id</code> attribute should be equal to the <code>list</code> attribute of <code>&lt;input&gt;</code> element to join them together.</p>
<pre class="language-markup"><code>&lt;label for="language"&gt;Select your favorite language&lt;/label&gt;
&lt;input list="languages" name="language"&gt;

&lt;datalist id="languages"&gt;
  &lt;option value="JavaScript"&gt;
  &lt;option value="Python"&gt;
  &lt;option value="Java"&gt;
  &lt;option value="Go"&gt;
  &lt;option value="Rust"&gt;
&lt;/datalist&gt;</code></pre>
<p style="text-align: center;"><label for="language">Select your favorite language</label> <input list="languages" name="language" type="text" />
<datalist id="languages">
<option value="JavaScript"></option>
<option value="Python"></option>
<option value="Java"></option>
<option value="Go"></option>
<option value="Rust"></option>
</datalist>
</p>
<p><code>&lt;datalist&gt;</code> also supports all global and event attributes.</p>
<h3 id="6-details-tag">6. details tag</h3>
<p><code>&lt;details&gt;</code> tag is used to provide additional details for a piece of text like an accordion. The additional details can be toggled easily.&nbsp;</p>
<p><code>&lt;summary&gt;</code> tag is used to display the visible text for the details. By default, it is closed and using <code>open</code> attribute we can make it open on the first time load.</p>
<pre class="language-markup"><code>&lt;details&gt;
  &lt;summary&gt;What is internet?&lt;/summary&gt;
  &lt;p&gt;Internet is a global connection of inter connected computer networks.&lt;/p&gt;
&lt;/details&gt;</code></pre>
<details>
<summary>What is internet?</summary>
<p>Internet is a global connection of inter-connected computer networks.</p>
</details>
<p><code>&lt;details&gt;</code> tag supports all global and event attributes</p>
<h3 id="7-description-list-tag">7. description list tag</h3>
<p><code>&lt;dl&gt;</code> is called a description list tag. It is along with <code>&lt;dt&gt;</code> and <code>&lt;dd&gt;</code> are used to show a description list.&nbsp;</p>
<p><code>&lt;dt&gt;</code> defines the description term and <code>&lt;dd&gt;</code> give the description of that term.</p>
<pre class="language-markup"><code>&lt;dl&gt;
  &lt;dt&gt;MERN&lt;/dt&gt;
  &lt;dd&gt;MongoDB, Express, React and Node&lt;/dd&gt;
  &lt;dt&gt;MEAN&lt;/dt&gt;
  &lt;dd&gt;MongoDB, Express, Angular and Node&lt;/dd&gt;
&lt;/dl&gt;</code></pre>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1642787622/devapt/description-list-html-tag.jpg" alt="description-list-html-tag" width="300" height="90" /></p>
<p><code>&lt;dl&gt;</code> tag supports all the global and even attributes.&nbsp;</p>
<h3 id="8-var-tag">8. var tag</h3>
<p><code>&lt;var&gt;</code> tag is used to represent the variables in a mathematical expression just like how we see in the printed books.&nbsp;</p>
<pre class="language-markup"><code>&lt;p&gt;The area of a circle of radius &lt;var&gt;r&lt;/var&gt; is represented by &amp;pi;&lt;var&gt;r&lt;/var&gt;&lt;sup&gt;2&lt;/sup&gt;&lt;/p&gt;</code></pre>
<p>The area of a circle of radius <var>r</var> is represented by &pi;<var>r</var><sup>2</sup></p>
<p>The default style applied to <code>&lt;var&gt;</code> tag is italic and it supports all global and event attributes.</p>
<h3 id="9-mark-tag">9. mark tag</h3>
<p><code>&lt;mark&gt;</code> tag is used to mark or highlight a piece of text in HTML.</p>
<pre class="language-markup"><code>&lt;p&gt;HTML is a &lt;mark&gt;markup&lt;/mark&gt; language, not a programming language.&lt;/p&gt;</code></pre>
<p>HTML is a <mark>markup</mark> language, not a programming language.</p>
<p><code>&lt;mark&gt;</code> tag also supports all the global attributes.</p>
<h3 id="10-noscript-tag">10. noscript tag</h3>
<p><code>&lt;noscript&gt;</code> tag is used to show alternate content to the users who have disabled JavaScript in their browser or if the JavaScript is not supported by their browser.&nbsp;</p>
<pre class="language-markup"><code>&lt;noscript&gt;Please enable JavaScript to see the content!&lt;/noscript&gt;</code></pre>
<noscript>Please enable JavaScript to see the content!</noscript>
<p>Above this line a <code>noscript</code> tag is inserted, if you disable the JavaScript you will be able to see that line.</p>
<p><code>&lt;noscript&gt;</code> tag can be used inside the head and the body tags.</p>
<p>There are a few more tags like &rarr; <code>&lt;picture&gt;</code>, <code>&lt;map&gt;</code>, <code>&lt;output&gt;</code>, <code>&lt;template&gt;</code> etc. You can start looking into them and use whatever is apt for your work.</p>
<p><span style="font-size: 24pt;">🔭</span> For a live demonstration of these HTML tags, you can check this <a href="https://codepen.io/Basharath/full/XWeOZvX" target="_blank" rel="noopener">codepen link</a>.</p>
<p>That's is all about the less often used HTML tags, you should know about.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Getting started with AWS DynamoDB NodeJS CRUD operations]]></title>
            <link>https://devapt.com/dynamodb-nodejs-crud</link>
            <guid isPermaLink="false">https://devapt.com/dynamodb-nodejs-crud</guid>
            <pubDate>Wed, 19 Jan 2022 08:45:42 GMT</pubDate>
            <description><![CDATA[AWS DynamoDB is a well-known NoSQL database. Here are the DynamoDB NodeJS CRUD operations with examples to help you get started using this NoSQL database.]]></description>
            <content:encoded><![CDATA[<p>DynamoDB is a well-known NoSQL database from Amazon Web Services(AWS). It offers a wide variety of features for free in its free tier program.</p>
<p>One can get started with DynamoDB in just a few minutes.&nbsp;But before that, you need to signup for an AWS account. Signing up for an AWS account can be done in a few simple steps, directly from the <em>aws.com</em> site.</p>
<p>Note you need to provide a credit or debit card to complete the signup. You will not be charged any amount until you cross their free tier service, so nothing to worry about 😊.&nbsp;</p>
<p>In the AWS free tier, you will get tonnes of features to use, of which some are limited for the first year and some are free even rest of the years until a certain threshold.</p>
<p>DynamoDB comes under always free service with&nbsp;</p>
<ul>
<li><strong>25</strong> GB&nbsp;of Storage</li>
<li><strong>25&nbsp;</strong>provisioned Write Capacity Units (WCU)</li>
<li><strong>25&nbsp;</strong>provisioned Read Capacity Units (RCU)</li>
</ul>
<p>and is said to handle up to 200M requests per month. If you go beyond that you will be charged the amount as per the extra usage.&nbsp;</p>
<blockquote>
<p>1 WCU = 1 write of up to 1 KB/s.</p>
<p>2 WCUs = 1 transactional write request (one write per second) for items up to 1 KB.</p>
</blockquote>
<blockquote>
<p>1 RCU =&nbsp; 1&nbsp; read of up to 4 KB/s&nbsp;</p>
<p>2 RCUs = 1 transactional read request (one read per second) for items up to 4 KB.</p>
</blockquote>
<p>To understand more about the read and write capacities check these <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.html" target="_blank" rel="noopener">aws docs</a>.</p>
<p>Once the AWS account is ready, you can set up the credentials locally for using the AWS services. Linux and Windows users can create <code>.aws</code> directory in the user folder and add the credentials file without any extension with the following details.</p>
<pre class="language-markup"><code>[default]
aws_access_key_id = &lt;YOUR_ACCESS_KEY_ID&gt;
aws_secret_access_key = &lt;YOUR_SECRET_ACCESS_KEY&gt;</code></pre>
<p>If you need more details for setting up the AWS credentials, follow up <a href="https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html" target="_blank" rel="noopener">this doc</a>.</p>
<p>Now let's get started with the DynamoDB NodeJS crud operations.&nbsp;</p>
<h2 id="dynamodb-nodejs-crud" style="text-align: center;">DynamoDB NodeJS CRUD</h2>
<p>Let's create a new directory <code>dynamo-crud</code> and initialize node project(you need to have node installed already).&nbsp;</p>
<pre class="language-bash"><code>mkdir dynamo-crud
cd dynamo-crud
npm init -y</code></pre>
<p>To get started with using AWS services we need <code>aws-sdk</code> package and we can install it using <code>npm</code>. You can learn the <a href="https://devapt.com/npm-commands-list" target="_blank" rel="noopener">npm commands from here</a>.</p>
<pre class="language-bash"><code>npm i aws-sdk</code></pre>
<p>For having unique IDs for our records or items, we can use <code>nanoid</code> package.</p>
<pre class="language-bash"><code>npm i nanoid</code></pre>
<p>Next create the <code>index.js</code>&nbsp;file in the root project directory.</p>
<p>After that configure AWS with your desired region and create DynamoDB instance. Keep in mind that we have already configured our credentials through a local file inside <code>.aws</code> directory.</p>
<pre class="language-javascript"><code>// Inside index.js
import AWS from 'aws-sdk';
import { nanoid } from 'nanoid';

AWS.config.update({ region: 'ap-south-1' });  // you can change region as per your preference

const DynamoDB = new AWS.DynamoDB(); // instance of DynamoDB</code></pre>
<h3 id="creating-table-in-dynamodb-nodejs">Creating table in DynamoDB NodeJS</h3>
<p>Now let's create a table named <code>Posts</code>. While creating the table we need to mention the unique key for querying the data.</p>
<p>In DynamoDB there are two key parameters, one is <strong><em>partition</em></strong> key and the other is <em><strong>sort</strong></em> key.</p>
<p>The primary key can be created using only the partition key or the combination of partition and sort key, known as composite primary key.</p>
<p>Having a sort key helps in sorting the data based on that sort key.</p>
<blockquote>
<p>In DynamoDB, tables, items, and attributes are the core components to work with. A <em>table</em>&nbsp;is a collection of&nbsp;<em>items</em>, and each item is a collection of&nbsp;<em>attributes</em>. DynamoDB uses primary keys to uniquely identify each item in a table and secondary indexes to provide more querying flexibility.</p>
</blockquote>
<p>We'll make a function for each operation so that it will be easier to use or reuse it and keep all related lines of code together.&nbsp;</p>
<pre class="language-javascript"><code>// Creating the table with parition key as the primary key
const createTable = () =&gt; {
  const params = {
    TableName: 'Posts',
    KeySchema: [{ AttributeName: 'postId', KeyType: 'HASH' }], // using partition key only
    AttributeDefinitions: [{ AttributeName: 'postId', AttributeType: 'S' }], // S for string
    ProvisionedThroughput: {
      ReadCapacityUnits: 5,
      WriteCapacityUnits: 5,
    },
  };

  DynamoDB.createTable(params, function (err, data) {
    if (err) {
      console.error('Unable to create table', err);
    } else {
      console.log('Created table', data);
    }
  });
};</code></pre>
<p>In the above code, we have created a table with name <code>Posts</code> and primary key <code>postId</code>. We have provisioned the capacity units 5 each RCU and WCU.&nbsp;</p>
<p>In <code>DynamoDB</code> instance by using <code>createTable</code> method we can pass the <code>params</code> and a callback with <code>err</code> and <code>data</code> arguments to create the table.</p>
<p>Calling the <code>creatTable()</code> function will run all the code inside it and will create the <code>Posts</code> table in the AWS DynamoDB space.</p>
<h3 id="creating-itemsrecords-in-dynamodb">Creating items/records in DynamoDB</h3>
<p>We'll create a function named <code>insertPost</code> that takes <code>postId</code>, <code>title</code> and <code>content</code> as arguments for creating the item with three key-value pairs.</p>
<p>We need <code>documentClient</code> instance for doing CRUD operations in the Dynamo database. With the following code snippet, we can create the instance of the <code>documentClient</code>.</p>
<pre class="language-javascript"><code>const documentClient = new AWS.DynamoDB.DocumentClient();</code></pre>
<p>Now initialize the function <code>insertPost</code> for inserting the items. We are going to use <code>put</code> method of <code>documentClient</code> for inserting the items.</p>
<pre class="language-javascript"><code>// Function to insert the post into Posts table/document
const insertPost = async (postId, title, content) =&gt; {
  const params = {
    TableName: 'Posts',
    Item: {
      postId,
      title,
      content,
    },
  };
  try {
    const data = await documentClient.put(params).promise();
    console.log('Post inserted', data);
  } catch (err) {
    console.log(err);
  }
};</code></pre>
<p>So we can now insert posts by calling the <code>insertPost</code> function with the data.&nbsp;</p>
<pre class="language-javascript"><code>// Inserting two posts
insertPost(
  nanoid(),
  'How to do CRUD operations in Dynamo?',
  'It is not that hard to do CRUD operations in DynamoDB.'
);
insertPost(
  nanoid(),
  'Sample title that can be deleted',
  'Sample description for the sample post'
);</code></pre>
<h3 id="reading-itemsrecords-in-dynamodb">Reading items/records in DynamoDB</h3>
<p>For reading the items we're going to create two functions, <code>getAllPosts</code> and <code>getSinglePost</code> functions.</p>
<p><code>scan</code> method of <code>documentClient</code> is used to get all the items in the table. <code>get</code> method is used to get a single item by using the primary key, nothing but the <code>postId</code> here.</p>
<pre class="language-javascript"><code>// Function to get all the posts
const getAllPosts = async (table) =&gt; {
  const params = {
    TableName: table,
  };
  try {
    const data = await documentClient.scan(params).promise();
    console.log(data);
    return data;
  } catch (err) {
    console.log(err);
  }
};

getAllPosts('Posts');

// Output:
// {
//   Items: [
//     {
//       content: 'Sample description for the sample post',
//       postId: 'FPbCFAvNoKWinPadsNBoW',
//       title: 'Sample title that can be deleted'
//     },
//     {
//       content: 'Follow this to learn about DyanamoDB',
//       postId: 'j6uv_RKuZg5XZll1AkAWx',
//       title: 'Learn to use DyanamoDB'
//     }
//   ],
//   Count: 2,
//   ScannedCount: 2
// }
</code></pre>
<p>By calling <code>getAllPosts('Posts')</code> with the table name we get all the posts.&nbsp;</p>
<pre class="language-javascript"><code>// Function to get single post from the table/document
const getSinglePost = async (table, keyObj) =&gt; {
  const params = {
    TableName: table,
    Key: keyObj,
  };
  try {
    const data = await documentClient.get(params).promise();
    console.log(data);
    return data;
  } catch (err) {
    console.log(err);
  }
};

getSinglePost('Posts', { postId: 'FPbCFAvNoKWinPadsNBoW' }); // gets single post</code></pre>
<p>By calling <code>getSinglePost(...)</code> with the table name and keyObj gets the single post.&nbsp;</p>
<h3 id="updating-items-in-dynamodb">Updating items in DynamoDB&nbsp;</h3>
<p>For updating the items we're going to create <code>updatePost</code> function.</p>
<p><code>put</code> method of <code>documentClient</code> is used for inserting and updating the item based on the primary key. If there's an item already existing then it will update else insert the item into the table.</p>
<pre class="language-javascript"><code>// Function to update the post based on postId
const updatePost = async (postId, title, content) =&gt; {
  const params = {
    TableName: 'Posts',
    Item: {
      postId,
      title,
      content,
    }
  };
  try {
    const data = await documentClient.put(params).promise();
    console.log('Post updated', data);
  } catch (err) {
    console.log(err);
  }
};
updatePost(
  'FPbCFAvNoKWinPadsNBoW',
  'Update sample post title',
  'Updated content'
);</code></pre>
<p>By calling <code>updatePost(...)</code> with <code>postId</code>, <code>title</code> and <code>content</code> will update that particular post.&nbsp;</p>
<h3 id="deleting-item-in-dynamodb">Deleting item in DynamoDB</h3>
<p>For deleting the item we're going to create <code>deletePost</code> function.</p>
<p><code>delete</code> method of <code>documentClient</code> is used for deleting the item based on the primary key.&nbsp;</p>
<pre class="language-javascript"><code>// Function to delete the post from posts table/document by postId
const deletePost = async (postId) =&gt; {
  const params = {
    TableName: 'Posts',
    Key: {
      postId,
    }
  };
  try {
    const data = await documentClient.delete(params).promise();
    console.log('Post deleted', data);
  } catch (err) {
    console.log(err);
  }
};
deletePost('FPbCFAvNoKWinPadsNBoW');</code></pre>
<p>By calling <code>deletePost(...)</code> function with <code>postId</code>, deletes the item from the <code>Posts</code> table.</p>
<p>That's the basic CRUD(Create, Read, Update, Delete) in DynamoDB using NodeJS. There are other methods and ways for querying data based on different conditions in AWS dynamodb. You can find the detailed documentation in these <a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html" target="_blank" rel="noopener">docs</a>.</p>
<p>You can find all the above-discussed codes in this <a href="https://github.com/Basharath/dynamodb-crud" target="_blank" rel="noopener">dynamodb-crud git repository</a>.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[4 ways to git undo last commit in simple and easy steps]]></title>
            <link>https://devapt.com/git-undo-last-commit</link>
            <guid isPermaLink="false">https://devapt.com/git-undo-last-commit</guid>
            <pubDate>Fri, 14 Jan 2022 08:45:49 GMT</pubDate>
            <description><![CDATA[Here are the 4 ways to git undo last commit in simple and easy steps. You can learn which git commands to use to undo commits effectively.]]></description>
            <content:encoded><![CDATA[<p>Git is a well-known version control system used by the majority of developers and organizations.&nbsp;</p>
<p>While making commits to the git repository there might be some accidental commits involving unintended changes or deletion of files.&nbsp;</p>
<p>In such a case, we can easily undo commits or changes with the help of a few git commands. Undoing git commits can be done in various methods based on how we wanted to keep the git history.&nbsp;</p>
<p>In this article, we're going to see those different methods to git undo commits.&nbsp;</p>
<p>Before actually diving into it, let's initialize git and commit a few files, so that we can use that to look into various git reverting commands.</p>
<p>Go to your favorite command line tool and run the below commands. Make sure that you have installed git in your system.</p>
<pre class="language-bash"><code># In the folder where you want to have a git repo
&gt; git init
&gt; echo One &gt; one.txt; echo Two &gt; two.txt; echo Three &gt; three.txt;  # Creating three files
&gt; git add one.txt
&gt; git commit -m "Adds one.txt"
&gt; git add two.txt
&gt; git commit -m "Adds two.txt"
&gt; git add three.txt
&gt; git commit -m "Adds three.txt"
&gt; git log --online

bdb52f3 (HEAD -&gt; master) Adds three.txt
c387fcb Adds two.txt
e99f4bf Adds one.txt</code></pre>
<p>Let's make some changes to a file and commit it.</p>
<pre class="language-bash"><code># Making changes to one.txt
&gt; echo Edited one &gt; one.txt
&gt; git commit -am "Updates one.txt" # Adding and committing directly
&gt; git log --oneline

8b730e8 (HEAD -&gt; master) Updates one.txt
bdb52f3 Adds three.txt
c387fcb Adds two.txt
e99f4bf Adds one.txt</code></pre>
<p>Now let's see how to git undo the last commit.</p>
<h2 id="4-ways-to-git-undo-last-commit" style="text-align: center;">4 ways to git undo last commit</h2>
<h3 id="1-using-git-revert">1. Using git revert</h3>
<p><code>git revert</code> command does the same as it states, that is it reverts any committed changes. This git command reverts the specified commit and creates a new commit with the reverted changes.&nbsp;</p>
<p>This is the most preferred git command for undoing or reverting any commits because this doesn't delete or orphan any of the commits. In short, this command doesn't rewrite the git history.</p>
<p>Let's see how to undo the commit using <code>git revert</code> command</p>
<pre class="language-bash"><code># Undoing the last commit using git revert
&gt; git revert HEAD</code></pre>
<p>To revert the last commit, we can use HEAD as it points to the last commit or we can use the hash of the commit we want to undo. By running the above command opens the configured editor to change the default message and once you close the editor, the last commit gets reverted with a new commit having "Revert" prefix to the actual commit name.&nbsp;</p>
<p>To avoid the editor from opening you can use <code>--no-edit</code> flag. To avoid committing the changes you can use <code>-n</code> or <code>--no-commit</code> flag as a result the reverted changes will be added to the staging(index) area without committing it.</p>
<pre class="language-bash"><code># Reverting without opening the editor
&gt; git revert --no-edit HEAD

# Reverting without committing the reverted changes
&gt; git revert -n HEAD</code></pre>
<p>Now let's see another way to git undo last commit.</p>
<h3 id="2-using-git-reset">2. Using git reset&nbsp;</h3>
<p>The git reset is a powerful command using which we can undo a series of previously committed changes. This command orphans the commits by resetting the head to a specified state.</p>
<p><code>git reset</code> takes the commit hash or reference from HEAD to which it is going to reset to. Once the git reset command is run, there won't be any latest commit logs up to the commit hash.</p>
<p>We can undo the last commit in three different forms with the <code>git reset</code> command. There are three flags that can be used with this command, --soft, --mixed(default), --hard.&nbsp;</p>
<p>On <code>--soft</code> reset, the commit gets removed and the changes get added to the staging area.&nbsp;</p>
<p>On <code>--mixed</code> reset(default), the commit gets removed and the changes get added to the local or working area.&nbsp;</p>
<p>On <code>--hard</code> reset, the commit gets removed and all the changes would be lost.&nbsp;</p>
<p>So based on your requirement you can pick the appropriate flag to undo the last commit.</p>
<pre class="language-bash"><code># Undoing the last commit using git reset
&gt; git reset HEAD^ # points to the commit before the last one

# To completely undo the commit
&gt; git reset --hard HEAD^</code></pre>
<p>Now let's see the third way to undo the last git commit.</p>
<h3 id="3-using-git-restore">3. Using git restore</h3>
<p>The <code>git restore</code> command is used to restore files in the working directory from the index or from other commits. We can also restore files to the index from other commits.&nbsp;</p>
<p><code>git restore</code> will not remove the previous commit logs or messages, it just restores the files or the directories as before.</p>
<pre class="language-bash"><code># Restoring the working directory from index
&gt; git restore .          # .(dot) means complete directory</code></pre>
<p>The above command just restores everything from the last commit. But what we want is to restore the commit before the last commit.&nbsp;</p>
<p>To restore files from other commits, git restore has <code>--source</code> flag, using that we can restore the parent of the last commit i.e., HEAD~1.</p>
<pre class="language-bash"><code># Undoing the last commit using git restore
&gt; git restore --source=HEAD~1 .</code></pre>
<p>By running the above command, the working directory will be with changes as that of the last commit's parent. It's just like <code>git revert -n HEAD</code> result but all the changes will be in the working directory not in the staging area.&nbsp;</p>
<p>To restore the changes to the staging area just use the <code>--staged</code> flag.&nbsp;</p>
<p>So using <code>git restore</code> command you will have the flexibility to commit changes with any message unlike git revert default message and also you can restore files specifically instead of the whole directory.&nbsp;</p>
<p>And now let's see the fourth way to undo the last git commit.</p>
<h3 id="4-using-git-rebase-i">4. Using git rebase -i</h3>
<p>The <code>git rebase -i</code> is a very powerful command for rewriting the git history. This command is used for rewording, editing, picking, dropping, squashing, etc commits.&nbsp;</p>
<p>git rebase with interactive flag helps to drop the commits. The same feature we can use to undo the last commit.&nbsp;</p>
<p>To make changes to the commit using <code>rebase -i</code> we need to go(rebase) to the parent of that commit and then make any changes we want.</p>
<pre class="language-bash"><code># Undoing the last commit using git rebase
&gt; git rebase -i HEAD~1 # select d - drop from the menu and proceed
</code></pre>
<p>When you run the above command your default editor gets opened with a list of actions you can perform on the last commit, select <code>d</code> or <code>drop</code> option and proceed. That will remove the last commit from the git log.&nbsp;</p>
<p>And that is how you can undo last git commit using rebase -i.</p>
<h3 id="points-to-note">Points to note</h3>
<p><code>git revert</code> and <code>git restore</code> will not modify the git history or log. So when dealing with collaborative works, it's good to use git revert and git restore for undoing the commits. This will help to maintain a clear log of all actions.&nbsp;</p>
<p><code>git reset</code> and <code>git rebase -i</code> will remove the logs of the commits. You can prefer this when your commits are local but in collaborative cases, you should strictly avoid using these because by chance you may end up rewriting the history of other people's commits.&nbsp;</p>
<p>Those are all the methods one can use to undo git commits. Which method to use depends on the individuals and their work environment.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[How to customize CSS list style type of each item?]]></title>
            <link>https://devapt.com/customize-css-list-style-type</link>
            <guid isPermaLink="false">https://devapt.com/customize-css-list-style-type</guid>
            <pubDate>Mon, 10 Jan 2022 08:45:58 GMT</pubDate>
            <description><![CDATA[Using CSS list style type you can change the style type of all items in the list. Here's how you can change the style type for individual items in the list]]></description>
            <content:encoded><![CDATA[<p>Lists are the form of data representation commonly used by all types of documents. In HTML there are two types of lists namely ordered and unordered lists.&nbsp;</p>
<p>In an ordered list, the items are indicated by serial numbers or letters that are in some order. In an unordered list, the list items are indicated by various types of bullets viz., disc, circle, square, or by an image.&nbsp;</p>
<p>By default, the ordered list items are indicated by numbers and unordered list items by disc bullets.</p>
<pre class="language-markup"><code>&lt;!-- Unordered list --&gt;
&lt;ul&gt;
  &lt;li&gt;Item 1&lt;/li&gt;
  &lt;li&gt;Item 2&lt;/li&gt;
  &lt;li&gt;Item 3&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- Ordered list --&gt;
&lt;ol&gt;
  &lt;li&gt;Item 1&lt;/li&gt;
  &lt;li&gt;Item 2&lt;/li&gt;
  &lt;li&gt;Item 3&lt;/li&gt;
&lt;/ol&gt;</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%; margin-left: auto; margin-right: auto;" border="0">
<tbody>
<tr>
<td style="width: 48.0477%; text-align: left; vertical-align: top;">
<p><strong>Ordered list</strong></p>
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
</td>
<td style="width: 48.0477%; text-align: left; vertical-align: top;">
<p><strong>Unordered list</strong></p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</td>
</tr>
</tbody>
</table></div>
<h2 id="styling-list-style-types" style="text-align: center;">Styling list style types</h2>
<p>For styling lists, there are CSS list properties using which we can change the list style type, list position, and add an image as a list type nothing but the image as the bullet of the list item.</p>
<h3 id="css-list-property">CSS list property</h3>
<pre class="language-css"><code>ul, ol {
  /* list-style is a shorthand property */
  list-style: list-style-type list-style-position list-style-image
}</code></pre>
<ul>
<li><code>list-style-type</code> - to change the bullet styles of the list</li>
<li><code>list-style-position</code> - to change the position of the list, two values outside and inside</li>
<li><code>list-style-image</code> - to add an image as a bullet for the list, if the image fails to show then list-style-type will be shown</li>
</ul>
<p>So in order to change the bullet type for the list, we just need to use CSS list style type with the bullet we need. Let's see how to change the bullets for the list.</p>
<pre class="language-css"><code>/* Unordered list */
ul {
  list-style-type: '❤️';
  or /* list-style: '❤️'; */
}

/* Orderedlist */
ol {
  list-style: '👍'
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 48.0477%;">
<p><strong>Unordered list</strong></p>
<ul style="list-style: '❤️';">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</td>
<td style="width: 48.0477%;">
<p><strong>Ordered list</strong></p>
<ol style="list-style: '👍';">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
</td>
</tr>
</tbody>
</table></div>
<p>Just by changing the CSS list style type value, we can change the bullets of any list. The possible value for the list style type can be anything, even language-specific letters, roman numerals, etc. To know various supported list style types in CSS head over to <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-type" target="_blank" rel="noopener">this MDN Docs</a>.</p>
<p>But using this way all the style types are going to be the same for all the items of the list. In order to customize style type for every individual item, we need to define it by using CSS at-rule, <code>@counter-style</code>.&nbsp;</p>
<h2 id="customize-individual-list-style-type" style="text-align: center;">Customize individual list style type</h2>
<p>Using <code>@counter-style</code> we can define the custom list style type for individual items of the list. It has so many properties for customizing the list. There are three important properties that we need to know to customize the list style types.</p>
<pre class="language-css"><code>@counter-style custom-type {
  system: cyclic;
  symbols: "😀";
  suffix: " ";
}

ul {
  list-style: custom-type;
  /*or list-style-type: custom-type; */
}</code></pre>
<ul>
<li><code>system</code> - defines how the list bullets should show. The possible values for it are: cyclic, numeric, alphabetic, symbolic, additive, or fixed, etc</li>
<li><code>symbols</code> - here is where you need to give different list style types you want to show for the list items. It can be numbers, alphabets, symbols, even images separated by a space</li>
<li><code>suffix</code> - usually, this one should be space, to have a space after the style type. Other than space you can have anything as a suffix.</li>
</ul>
<p>Let's see all the above in action.</p>
<pre class="language-markup"><code>&lt;!-- Unordered list --&gt;
&lt;ul&gt;
  &lt;li&gt;One&lt;/li&gt;
  &lt;li&gt;Two&lt;/li&gt;
  &lt;li&gt;Three&lt;/li&gt;
  &lt;li&gt;Four&lt;/li&gt;
&lt;/ul&gt;

&lt;!-- Ordered list --&gt;
&lt;ol&gt;
  &lt;li&gt;One&lt;/li&gt;
  &lt;li&gt;Two&lt;/li&gt;
  &lt;li&gt;Three&lt;/li&gt;
  &lt;li&gt;Four&lt;/li&gt;
&lt;/ol&gt;</code></pre>
<pre class="language-css"><code>/* style type for unordered list */
@counter-style custom-unordered {
  system: cyclic;
  symbols:  '❓' '✌️' '❤️' ;
  suffix: ' ';
}

/* style type for ordered list */
@counter-style custom-ordered {
  system: fixed;
  symbols: '➡️' '😀' '👍';
  suffix: ' ';
}

ul {
  list-style: custom-unordered;
  /* or list-style-type: custom-unordered; */
}
ol {
  list-style-type: custom-ordered;
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 48.0477%;">
<p><strong>Unordered list</strong></p>
<ul style="list-style: custom-unordered;">
<li>One</li>
<li>Two&nbsp;</li>
<li>Three</li>
<li>Four</li>
</ul>
</td>
<td style="width: 48.0477%;">
<p><strong>Ordered list</strong></p>
<ol style="list-style-type: custom-ordered;">
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
</ol>
</td>
</tr>
</tbody>
</table></div>
<p>So using the @counter-style that is how we can add individual list style types. If you see when <code>system</code> is defined as <code>cyclic</code> the same list style type repeats after all types are done, and when it is <code>fixed</code> the style type for the item number more than the number of symbols defined, get the default style type i.e., a number for the ordered list and disc for the unordered list.</p>
<p>You need <code>system</code> value as <code>fixed</code> only when you know that the number of items are fixed else it's better to go for <code>cyclic</code> or any other type.&nbsp;</p>
<p>That is all about styling the individual list item types using CSS.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[CSS gradients linear, radial & conic all you need to know about]]></title>
            <link>https://devapt.com/css-gradient-linear-radial-conic</link>
            <guid isPermaLink="false">https://devapt.com/css-gradient-linear-radial-conic</guid>
            <pubDate>Fri, 07 Jan 2022 08:45:53 GMT</pubDate>
            <description><![CDATA[CSS gradients are the color gradients using CSS. There are three types of color gradients in CSS. Linear gradient, radial gradient and conic gradient.]]></description>
            <content:encoded><![CDATA[<p>CSS gradients are nothing but the color gradients using CSS. A color gradient or a color transition is the gradual blending of colors from one color to the other color. This color transition can happen between a minimum of two colors to any number of colors.</p>
<p>CSS is a styling language for HTML markup and so it deals with the colors.&nbsp;</p>
<p>In CSS there are three types of color gradients:</p>
<ol>
<li>Linear gradient</li>
<li>Radial gradient</li>
<li>Conic gradient</li>
</ol>
<p>Let's see how to generate each type of CSS gradient.</p>
<h2 id="1-css-linear-gradient">1. CSS linear gradient</h2>
<p>A linear gradient is a color gradient where the transition of colors happen linearly. To generate a linear gradient at least two colors are needed and these are often called <strong>color stops</strong>.&nbsp;</p>
<p>Though linear gradients are linear we can choose the direction of this linearity, it could be horizontal, vertical, diagonal, or in the specific angle direction.&nbsp;</p>
<p>To generate a linear gradient using CSS we use the <code>linear-gradient</code> CSS function with a minimum of two arguments. This linear gradient value is assigned to the background-image property of CSS.</p>
<pre class="language-css"><code>background-image: linear-gradient([direction], color-stop1, color-stop2, ...);</code></pre>
<p>In the above CSS snippet, the default direction is top to bottom and so it can be omitted if we want to go by default direction. <em>The color stops can be of any valid CSS colors e.g., blue, #0000FF, rgb(0, 0, 255), rgba(0, 0, 255, 0.2) etc for all types of gradients in CSS.</em></p>
<p>Let's see an example.</p>
<pre class="language-markup"><code>&lt;!-- HTML that we consider for all linear-gradients --&gt;
&lt;div class="box" style="width: 100%; height: 75px"&gt;&lt;/div&gt;</code></pre>
<pre class="language-css"><code>.box {
  background-image: linear-gradient(blue, red);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100%;" border="1">
<tbody>
<tr>
<td style="background-image: linear-gradient(blue, red); height: 75px; width: 100%; text-align: center;"><span style="color: #ecf0f1;">(from top) to bottom (default)</span></td>
</tr>
</tbody>
</table></div>
<p>We can see that the linear gradient from blue to red is applied in the default direction from top to bottom.</p>
<h3 id="the-available-values-for-the-direction-are"><strong>The available values for the direction are:</strong></h3>
<p><strong>For horizontal &amp; vertical: </strong>to right, to left, to bottom, to top</p>
<p><strong>For diagonal: </strong>to bottom right, to bottom left, to top right, to top left</p>
<p><strong>For angle: </strong>(0 to 360)deg</p>
<h4><strong>Example for a horizontal gradient:</strong></h4>
<pre class="language-css"><code>.box {
  background-image: linear-gradient(to right, blue, red);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 75px; background-image: linear-gradient(to right, blue, red); text-align: center;"><span style="color: #ecf0f1;">(from left) to right</span></td>
</tr>
</tbody>
</table></div>
<p>---</p>
<h4><strong>Example for more than two colors' gradient:</strong></h4>
<pre class="language-css"><code>.box {
  background-image: linear-gradient(to top, blue, red, yellow);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 75px; background-image: linear-gradient(to top, blue, red, yellow); text-align: center;"><span style="color: #ecf0f1;">(from bottom) to top</span></td>
</tr>
</tbody>
</table></div>
<p>---</p>
<h4><strong>Example for a diagonal gradient:</strong></h4>
<pre class="language-css"><code>.box {
  background-image: linear-gradient(to bottom right, blue, red);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; background-image: linear-gradient(to right bottom, blue, red); height: 75px; text-align: center;"><span style="color: #ecf0f1;">(from top left) to bottom right</span></td>
</tr>
</tbody>
</table></div>
<p>---</p>
<h4><strong>Example for an angle gradient:</strong></h4>
<p>The angle direction will be clockwise and it starts from the top like 12'O clock. So 0deg is equivalent to <code>to top</code>, 90deg equivalent to <code>to right</code>, 180deg equivalent to <code>to bottom</code> and so on.</p>
<pre class="language-css"><code>.box {
  background-image: linear-gradient(120deg, blue, red);
}
</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 75px; background-image: linear-gradient(120deg, blue, red); text-align: center;"><span style="color: #ecf0f1;">120deg(towards bottom)</span></td>
</tr>
</tbody>
</table></div>
<p>---</p>
<h4><strong>Example for a specific color-stop location gradient:</strong></h4>
<p>You can specify the location of the color stop explicitly by percentage or in px after the color. This value can be negative in order to start the transition much before the starting point and can be more than 100% to end the transition far after the ending point.</p>
<pre class="language-css"><code>.box {
  background-image: linear-gradient(to right, blue 60%, red 110%);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 75px; background-image: linear-gradient(to right, blue 60%, red 110%); text-align: center;"><span style="color: #ecf0f1;">to right (color stop location 60% for blue and 110% for red)</span></td>
</tr>
</tbody>
</table></div>
<pre class="language-css"><code>.box {
  background-image: linear-gradient(to right, blue -30%, red 90%);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 75px; background-image: linear-gradient(to right, blue -30%, red 90%); text-align: center;"><span style="color: #ecf0f1;">to right (color stop location -30% for blue, 90% for red)</span></td>
</tr>
</tbody>
</table></div>
<p>---</p>
<h4>Example for a hard-lined linear gradient:</h4>
<pre class="language-css"><code>.box {
  background-image: linear-gradient(to right, blue 50%, red 50%);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 75px; background-image: linear-gradient(to right, blue 50%, red 50%); text-align: center;"><span style="color: #ecf0f1;">to right(hard lined)</span></td>
</tr>
</tbody>
</table></div>
<p>---</p>
<h4>Example for creating color bands with two color stops:</h4>
<p>You can have multiple stops for the color indicating the start and stop. Using this method you can create bands of colors.</p>
<pre class="language-css"><code>.box {
  background-image: linear-gradient(
    to right,
    blue 25%,
    red 25%,
    red 50%,
    green 50%,
    green 75%,
    yellow 75%
  );
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 75px; background-image: linear-gradient(to right,blue 25%,red 25%,red 50%,green 50%, green 75%,yellow 75%); text-align: center;"><span style="color: #ecf0f1;">to right(blue, red, green, yellow bands)</span></td>
</tr>
</tbody>
</table></div>
<p>---</p>
<h4><strong>Example for a repeating linear gradient:</strong></h4>
<p>We can repeat the linear gradient by using <code>repeating-linear-gradient</code> function, instead of <code>linear-gradient</code>.</p>
<pre class="language-css"><code>.box {
  background-image: repeating-linear-gradient(to right, blue 20%, red 40%);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 75px; background-image: repeating-linear-gradient(to right, blue 20%, red 40%); text-align: center;"><span style="color: #ecf0f1;">repeating linear gradient</span></td>
</tr>
</tbody>
</table></div>
<p>And that is all about linear gradients in CSS. Let's see CSS radial gradients.</p>
<p>&nbsp;</p>
<h2 id="2-css-radial-gradient">2. CSS radial gradient</h2>
<p>A radial gradient is a color gradient where the transition of colors happen in a radial fashion i.e., the colors transition from a central point.</p>
<p>To generate a radial gradient at least two colors are needed just like the linear gradient.</p>
<p>Radial gradiants can be made circular or elliptical. By <strong>default</strong>, the center of the <strong>gradient</strong> is at the <strong>50% 50%</strong> mark, shape is <strong>elliptical</strong>, size is <strong>farthest-corner</strong>.&nbsp;</p>
<pre class="language-css"><code>background-image: radial-gradient([shape size at position], color-stop1, color-stop2, ...);</code></pre>
<p>Let's see an example</p>
<pre class="language-markup"><code>&lt;!-- HTML that we consider for all radial-gradients --&gt;
&lt;div class="box" style="width: 100%; height: 100px"&gt;&lt;/div&gt;</code></pre>
<pre class="language-css"><code>.box {
    background-image: radial-gradient(blue, red);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 100px; background-image: radial-gradient(blue, red); text-align: center;"><span style="color: #ecf0f1;">elliptical farthest-corner, center</span></td>
</tr>
</tbody>
</table></div>
<p>The <strong>possible values for the shape</strong> are <code>circle</code> and <code>ellipse</code></p>
<p>The <strong>possible values for the radiance or gradient size</strong> are:&nbsp;</p>
<ul>
<li>closest-side</li>
<li>farthest-side</li>
<li>closest-corner</li>
<li>farthest-corner</li>
</ul>
<p>For <strong>circle</strong> size can be given in terms of <strong>length</strong>(px, rem, em). e.g., circle 50px</p>
<p>For <strong>ellipse</strong> size can be given in terms of <strong>length or percentage</strong>. e.g., ellipse 100px, 30px, first length/percentage indicates horizontal radius and the second length/percentage indicates vertical radius of the ellipse.</p>
<p>Similar to the linear-gradient, we can choose the color stop location with a percentage or length after the color.&nbsp;</p>
<p>Let's see examples for each type of radial gradient.</p>
<h4>Example for a circle shaped radial-gradient:</h4>
<pre class="language-css"><code>.box {
  /* default size and position will be considered */
  background: radial-gradient(circle, blue, red);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 100px; background: radial-gradient(circle, blue, red); text-align: center;"><span style="color: #ecf0f1;">circle shape radial gradient</span></td>
</tr>
</tbody>
</table></div>
<p>---</p>
<h4>Example for a radial gradient with shape, size and position:</h4>
<pre class="language-javascript"><code>.box {
  background: radial-gradient(circle closest-side at 20% 50%, blue, red);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 100px; background: radial-gradient(circle closest-side at 20% 50%, blue, red); text-align: center;"><span style="color: #ecf0f1;">circle shape radial gradient with closest-side size</span></td>
</tr>
</tbody>
</table></div>
<p>---</p>
<h4>Example for a radial gradient with circle length:</h4>
<pre class="language-css"><code>.box {
  /* default position is considered, 50px is the size, circle is the shape */
  background: radial-gradient(circle 50px, royalBlue 10%, Cyan 20%, Tomato 60%, SpringGreen);
}
</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 100px; background: radial-gradient(circle 50px, royalBlue 10%, Cyan 20%, Tomato 60%, SpringGreen); text-align: center;">&nbsp;</td>
</tr>
</tbody>
</table></div>
<p>If you are wondering how to know those different color names for direct use, then you can have a look at this <a href="https://devapt.com/color-names-hex-color-codes" target="_blank" rel="noopener">CSS color names to use directly</a> article.</p>
<p>---</p>
<h4>Example for a repeating radial gradient:</h4>
<p>Just like in linear gradient we can also have repeating transitions of radial gradient using <code>repeating-radial-gradient</code> CSS function. All the parameters remain just like the normal radial gradient.</p>
<pre class="language-css"><code>.box {
  /* 20px 10px is the size of the ellipse and default position center */
  background: repeating-radial-gradient(ellipse 20px 10px, royalBlue 10%, Cyan 20%, Tomato 60%, SpringGreen);
}</code></pre>
<div class="table-scroll"><table style="border-collapse: collapse; width: 100.006%;" border="1">
<tbody>
<tr>
<td style="width: 97.9764%; height: 100px; background: repeating-radial-gradient(ellipse 20px 10px, royalBlue 10%, Cyan 20%, Tomato 60%, SpringGreen); text-align: center;"><span style="color: #000000; background-color: #ecf0f1;">&nbsp;repeating radial gradient in ellipse shape&nbsp;</span></td>
</tr>
</tbody>
</table></div>
<p>That is all about radial-gradients in CSS. Let's go to the last CSS gradient type conic.</p>
<p>&nbsp;</p>
<h2 id="3-css-conic-gradient">3. CSS conic gradient</h2>
<p>A conic gradient is a color gradient where the transition of colors happen in a rotated fashion i.e., the colors transition at angles from a point.</p>
<p>To generate a conic gradient at least two colors are needed just like the linear and radial gradient.</p>
<p>By <strong>default</strong>, the position of the gradient is at 50% 50% mark or at&nbsp; <strong>center</strong> and starting or from angle is <strong>0deg</strong>. These degrees start from top, like starting from 12'O clock in clockwise direction.&nbsp;</p>
<pre class="language-css"><code>background-image: conic-gradient([from angle] [at position,] color-stop1 [deg], color-stop2 [deg], ...);</code></pre>
<p>Let's see a quick example of this conic gradient:</p>
<pre class="language-markup"><code>&lt;!-- HTML that we consider for all conic-gradients --&gt;
&lt;div class="box" style="width: 100px; height: 100px"&gt;&lt;/div&gt;</code></pre>
<pre class="language-css"><code>.box {
  background: conic-gradient(blue, red);
}</code></pre>
<div class="table-scroll"><table class="flex justify-center w-fit" style="border-collapse: collapse; margin-left: auto; margin-right: auto;" border="1">
<tbody>
<tr>
<td style="width: 100px; height: 100px; background: conic-gradient(blue, red); text-align: center;">&nbsp;</td>
</tr>
</tbody>
</table></div>
<p style="text-align: center;"><strong>Conic gradient with default position and angle</strong></p>
<p>In the above conic gradient we can see the gradient position at center and the starting angle 0deg.&nbsp;</p>
<p>The possible values of <strong>from angle</strong> are: (0-360)deg</p>
<p>The possible values of<strong> position</strong> of the conic gradient are in percentage or in pixels.</p>
<p>e.g.,50% 50%.</p>
<p>Let's see examples for each type of conic gradient.</p>
<h4>Example for a conic gradient with more than two colors:</h4>
<pre class="language-css"><code>.box {
  /* default angle 0deg, position center */
  background: conic-gradient(blue, red, green, tomato, hotpink);
}</code></pre>
<div class="table-scroll"><table class="flex justify-center w-fit" style="border-collapse: collapse; margin-left: auto; margin-right: auto;" border="1">
<tbody>
<tr>
<td style="width: 100px; height: 100px; background: conic-gradient(blue, red, green, tomato, hotpink); text-align: center;">&nbsp;</td>
</tr>
</tbody>
</table></div>
<p style="text-align: center;"><strong>Multi colored conic gradient</strong></p>
<p>---</p>
<h4>Example for a conic gradient with color stop degrees:</h4>
<pre class="language-css"><code>.box {
  background: conic-gradient(blue 60deg, red 120deg, green 270deg);
}</code></pre>
<div class="table-scroll"><table class="flex justify-center w-fit" style="border-collapse: collapse; margin-left: auto; margin-right: auto;" border="1">
<tbody>
<tr>
<td style="width: 100px; height: 100px; background: conic-gradient(blue 60deg, red 120deg, green 270deg); text-align: center;">&nbsp;</td>
</tr>
</tbody>
</table></div>
<p style="text-align: center;"><strong>Conic gradient with color stop angles</strong></p>
<p>---</p>
<h4>Example for conic gradient with initial degree and position:</h4>
<pre class="language-css"><code>.box {
  background: conic-gradient(from 90deg at 60% 40%, blue 60deg, red 120deg, green 270deg);
}</code></pre>
<div class="table-scroll"><table class="flex justify-center w-fit" style="border-collapse: collapse; margin-left: auto; margin-right: auto;" border="1">
<tbody>
<tr>
<td style="width: 100px; height: 100px; background: conic-gradient(from 90deg at 60% 40%, blue 60deg, red 120deg, green 270deg); text-align: center;">&nbsp;</td>
</tr>
</tbody>
</table></div>
<p style="text-align: center;"><strong>Conic-gradient with a specific from angle and position</strong></p>
<p>---</p>
<h4>Example for a conic gradient pie-chart:</h4>
<p>You can create a pie-chart with the help of conic gradient. By using start and stop, color stops for each color we can create hard-lined separations. This is something like the color band that we have seen in linear-gradients, but this one will be in degrees. And to make it appear like a circle instead of a square, we just need to make the border-radius to 50%.</p>
<pre class="language-css"><code>.box {
  background: conic-gradient(from 90deg, blue 120deg, red 120deg, red 240deg, green 240deg, green 360deg);
  border-radius: 50%;
}</code></pre>
<div class="table-scroll"><table class="flex justify-center w-fit" style="border-collapse: collapse; margin-left: auto; margin-right: auto;">
<tbody>
<tr>
<td style="width: 100px; height: 100px; background: conic-gradient(from 90deg, blue 120deg, red 120deg, red 240deg, green 240deg, green 360deg); border-radius: 50%; text-align: center;">&nbsp;</td>
</tr>
</tbody>
</table></div>
<p style="text-align: center;"><strong><span style="color: #000000;">Pie-chart with conic gradient</span></strong></p>
<p><span style="color: #000000;">---</span></p>
<h4>Example for a repeating conic gradient:</h4>
<p>Just like in linear and radial gradients we can also have repeating transitions of conic gradient using <code>repeating-conic-gradient</code> CSS function. All the parameters remain just like the normal conic gradient.</p>
<pre class="language-css"><code>.box {
  background: repeating-conic-gradient(blue 30deg, red 90deg); 
  border-radius: 50%;
}</code></pre>
<div class="table-scroll"><table class="flex justify-center w-fit" style="border-collapse: collapse; margin-left: auto; margin-right: auto;" border="1">
<tbody>
<tr>
<td style="width: 100px; height: 100px; background: repeating-conic-gradient(blue 30deg, red 90deg); border-radius: 50%; text-align: center;">&nbsp;</td>
</tr>
</tbody>
</table></div>
<p style="text-align: center;"><strong><span style="color: #000000;">Repeating conic gradient in a circle shape</span></strong></p>
<p>And that is all about different types of CSS gradients. Hope this article has given a clear insight in generating gradients with CSS.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Event bubbling in JavaScript all you need to know about]]></title>
            <link>https://devapt.com/event-bubbling-javascript</link>
            <guid isPermaLink="false">https://devapt.com/event-bubbling-javascript</guid>
            <pubDate>Thu, 06 Jan 2022 08:45:08 GMT</pubDate>
            <description><![CDATA[Event bubbling in JavaScript is the default behavior of how events propagate from the innermost element to the outermost parent. Here are all the details.]]></description>
            <content:encoded><![CDATA[<p>The interactivity on webpages in the browser happens with the help of JavaScript. Javascript calls every action that happens on the webpage as an event. There's a way how events get propagated in different directions in the DOM(Document Object Model) tree.</p>
<blockquote>
<p>Event bubbling in Javascript refers to the way how events get propagated from the innermost element to the outermost element of the DOM often the <code>document</code>.</p>
</blockquote>
<h2 id="event-bubbling-in-javascript" style="text-align: center;">Event bubbling in JavaScript</h2>
<p>When an event happens on an element, the event handler attached to that element runs first, then parent's handler and followed by all other ancestors' handlers. This is what bubbling in JavaScript is.</p>
<p>Let's understand it better with the help of a simple example.</p>
<pre class="language-javascript"><code>&lt;article onclick="alert('article')"&gt;
  &lt;section onclick="alert('section')"&gt;
    &lt;div onclick="alert('div')"&gt;Text to click&lt;/div&gt;
  &lt;/section&gt;
&lt;/article&gt;
</code></pre>
<p>When you run the above code snippet in the browser and click on the text, you can see an <a href="https://devapt.com/javascript-popup-boxes" target="_blank" rel="noopener">alert box</a> with <code>div</code> message, followed by another alert with <code>section</code> message and it is followed by another alert with <code>article</code> message.&nbsp;</p>
<p>And that shows clearly that our event of clicking is propagating up and triggering other event handlers on the parent and ancestor elements of <code>div</code>. And this even propagation won't stop until the <code>article</code> element, it keeps going and going until it reaches <code>html</code> element and then to the <code>document</code> object.</p>
<p>Event bubbling is the default behaviour in JavaScript and it has various use cases, like sometimes analytic tools want to capture user moments, clicks etc and all such things happen because of event bubbling.&nbsp;</p>
<p>Similar to bubbling there's another concept called event capturing and this works opposite to bubbling.</p>
<p><em>In <strong>bubbling</strong> events propagate from the innermost element to the outermost parent and in <strong>capturing</strong> events propagate from the outermost parent to the innermost element.</em></p>
<h2 id="stop-event-bubbling-in-javascript" style="text-align: center;">Stop event bubbling in Javascript</h2>
<p>It's very simple to stop event bubbling on an element that is to stop triggering the handlers of its parent and ancestor elements.</p>
<p>Let's see the same example to stop this bubbling.</p>
<pre class="language-javascript"><code>&lt;article onclick="alert('article')"&gt;
  &lt;section onclick="alert('section')"&gt;
    &lt;div onclick="event.stopPropagation()"&gt;Text to click&lt;/div&gt;
    &lt;p&gt;Paragraph text&lt;/p&gt;
  &lt;/section&gt;
&lt;/article&gt;</code></pre>
<p>In the above code snippet we have added <code>event.stopPropagation()</code> on the div handler and a new paragraph of text.&nbsp;</p>
<p>When you click on the div text, nothing happens because we are preventing the event from bubbling, but when you click the paragraph text it bubbles up and triggers the <code>section</code> and <code>article</code> elements' handlers.&nbsp;</p>
<p>And that's so simple to prevent even bubbling. But in most cases, you don't need to prevent this bubbling of events, and only under specific scenarios you need this <code>stopPropagation</code> method for stopping the bubbling.</p>
<pre class="language-javascript"><code>&lt;div onclick="event.stopPropagation()"&gt;Text to click&lt;/div&gt;</code></pre>
<p>The way we have handled the event on <code>div</code> element is the old style of running event handlers and it's not an effective way to handle events like this.&nbsp;</p>
<h2 id="preferred-way-to-handle-events" style="text-align: center;">Preferred way to handle events</h2>
<p>The preferred way to handle events on any elements is by using <code>addEventListener</code> method on it.</p>
<pre class="language-javascript"><code>document.addEventListener(event, function, useCapture);</code></pre>
<ul>
<li><strong>event</strong> - type of the event to listen e.g., click, mouseover etc</li>
<li><strong>function</strong> - function to run after the event occurs</li>
<li><strong>useCapture</strong> - boolen(default false), if true event propagation happens from parent to the innert most element(child)</li>
</ul>
<p>So let's see this by considering an example</p>
<h3 id="event-bubbling-and-capturing-with-addeventlistener">Event bubbling and capturing with addEventListener</h3>
<pre class="language-javascript"><code>// Event bubbling
&lt;section&gt;
  &lt;div&gt;Text to click&lt;/div&gt;
&lt;/section&gt;

&lt;script&gt;
const section = document.querySelector('section');
const div = document.querySelector('div');

div.addEventListener('click', (e) =&gt; alert('From div'));
section.addEventListener('click', (e) =&gt; alert('From section'));
&lt;/script&gt;</code></pre>
<p>In this event bubbling happens when you click the div text, the event gets propagated to the <code>section</code> handlers and triggers it.</p>
<p>To reverse the event bubbling to go from parent to child, you can just enable the useCapture flag on the parent element.</p>
<pre class="language-javascript"><code>// Passing third argument with true, 
// enables the section handler to trigger first before div
section.addEventListener('click', () =&gt; alert('From section'), true);</code></pre>
<h3 id="stop-event-propagation-with-addeventlistener">Stop event propagation with addEventListener</h3>
<p>To stop the event propagation just call the <code>stopPropagation</code> method on the event object of the element you want.</p>
<pre class="language-javascript"><code>const section = document.querySelector('section');
const div = document.querySelector('div');

div.addEventListener('click', (e) =&gt; {
  e.stopPropagation(); // stops propagation to its parent element
  alert('From div');
});

section.addEventListener('click', () =&gt; alert('From section'));</code></pre>
<p>This time when you click the div text, only the div handler runs and there won't be any alert message from <code>section</code> handler.</p>
<p>There's one more method for stopping the propagation of events, it is called <code>stopImmediatePropagation</code> method. This prevents running other handlers when there are multiple event handlers on the same element.&nbsp;</p>
<p>And this is all about event bubbling in Javascript. Event listeners and event handlers are a very broad topic in Javascript and there are so many things that can be discussed related to the events in JS.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Javascript setTimeout and setInterval all you need to know]]></title>
            <link>https://devapt.com/javascript-settimeout-setinterval</link>
            <guid isPermaLink="false">https://devapt.com/javascript-settimeout-setinterval</guid>
            <pubDate>Wed, 05 Jan 2022 08:45:21 GMT</pubDate>
            <description><![CDATA[Javascript setTimeout and setInterval are the two global methods for timing or scheduling function calls. Here is all you need to know about these methods.]]></description>
            <content:encoded><![CDATA[<p>Javascript has so many global methods and properties that can be accessed in any part of the JS code. <code>setTimeout</code> and <code>setInterval</code> are two of the most essential JS methods.</p>
<p><code>setTimeout</code> and <code>setInterval</code> are attached to the <code>window</code> object, they can be accessed prefixing with <code>window</code> object like <code>window.setTimeout()</code> and <code>window.setInterval()</code> or more often without the prefix.</p>
<blockquote>
<p>Global methods and properties need not be prefixed with window object and only if in cases you want to make sure that you are in browser environment and want to access global method or property, then prefix with <code>window</code> object.</p>
</blockquote>
<p>The way Javascript setTimeout and setInterval work are very similar. These are used to work with the timing or scheduling of functions.&nbsp;</p>
<h2 id="javascript-settimeout" style="text-align: center;">Javascript setTimeout</h2>
<p>The setTimeout Javascript method sets a timer and executes a function passed to it once the timer expires.</p>
<p>Basically, the <code>setTimeout</code> method takes a function or the function reference as the first argument, followed by the optional arguments, delay, and the arguments to the function. Whenever the delay gets expired, the function gets executed or called.</p>
<pre class="language-javascript"><code>setTimeout(function() {}, delay, arg1, arg2, ...);</code></pre>
<p>Let's see it by a simple example.</p>
<pre class="language-javascript"><code>setTimeout(() =&gt; {
  console.log('Hi');
}, 2000); 
// After 2 seconds logs:
// Hi</code></pre>
<p>In the above example, after 2 seconds text gets logged in the console. The delay argument in the setTimeout method should be in milliseconds. If there's no delay given, <strong>0ms</strong> will be the default delay.</p>
<pre class="language-javascript"><code>const getData = (type = 'json') =&gt; {
  console.log('Getting data of type ' + type);
}
setTimeout(getData, 5000, 'markdown');
// After 5 seconds logs:
// Getting data of type markdown
----
setTimeout(getData);
// Logs immediately:
// Getting data of type json</code></pre>
<p>In the above code snippet, we can see that the third argument in the setTimeout is passed to the <code>getData</code> function. All arguments other than the first two gets passed to the function, in this case, it is <code>getData</code>.&nbsp;</p>
<p>If in case if we want to stop the function from being executed before the timer expires, we can do that by using the <code>clearTimeout</code> global method of Javascript.</p>
<p>Every setTimeout method returns a unique timer ID using which we can clear that scheduled timer.</p>
<pre class="language-javascript"><code>const logger = () =&gt; {
  console.log('Logging details');
}
const timerId = setTimeout(logger, 5000);

// If called before the timer expires, logger function won't be executed
clearTimeout(timerId);</code></pre>
<p>In the above code snippet, we can see the <code>clearTimeout</code> being called before the timer expires as a result setTimeout won't execute the <code>logger</code> function.&nbsp;</p>
<p><code>clearTimeout</code> can be called with the timer ID, inside any function based on different conditions to stop <code>setTimeout</code> executing the function.&nbsp;</p>
<h3 id="points-to-note-for-settimeout">Points to note for setTimeout:</h3>
<ol>
<li><code>setTimeout</code> is an asynchronous function which means the code that comes after it won't wait for it to complete.</li>
<li>The first argument of <code>setTimeout</code> takes a function reference which it calls once the timer expires, but often people call the function instead of passing the reference, as a result, whatever is returned from the function is executed by the <code>setTimeout</code>
<pre class="language-javascript"><code>const greet = function() { console.log('Hi')};

setTimeout(greet(), 5000); // greet gets executed without delay, it returns undefined as first argument to setTimeout
setTimeout(greet, 5000);  // greet gets executed after 5 seconds
</code></pre>
</li>
<li>The <code>this</code> keyword will not behave as expected inside <code>setTimeout</code>. In such situations, you can use arrow functions as they bind <code>this</code> to the function scope, they are created in.
<pre class="language-javascript"><code>const person = {
  name: 'John',
  greetFunc: function () {
    setTimeout(function () {
      console.log(`Hi, ${this.name}`);
    }, 2000);
  },
  greetArrow: function () {
    setTimeout(() =&gt; console.log(`Hi, ${this.name}`), 2000);
  },
};

person.greetFunc(); // Hi, undefined
person.greetArrow(); // Hi, John</code></pre>
</li>
<li><code>setTimeout</code> with <strong>0ms</strong> will not be executed immediately as it looks. It is executed after all the script is run, because it's an asynchronous function that is sent to the event loop before getting to the call stack.
<pre class="language-javascript"><code>console.log('First statement');
setTimeout(() =&gt; console.log('Second statement'), 0); // delay can be omitted it's the default value
console.log('Third statement');

// Log result(observe the order):
// First statement
// Third statement
// Second statement</code></pre>
</li>
</ol>
<p>Now let's get into the setInterval of Javascript.</p>
<h2 id="javascript-setinterval" style="text-align: center;">Javascript setInterval</h2>
<p>The setInterval Javascript method calls a function passed to it at every interval of time until unless it is stopped.</p>
<p>So it is similar to the <code>setTimeout</code>, but instead of calling the function once it keeps calling it at regular intervals until it gets stopped.</p>
<p>The <code>seteInterval</code> method takes a function or a function reference as the first argument, followed by the optional arguments, delay(time interval), and the arguments to the function. The function gets executed or called, with a fixed time delay between each call.</p>
<pre class="language-javascript"><code>setInterval(function() {}, delay, arg1, arg2, ...);</code></pre>
<p>Let's see it with a simple example</p>
<pre class="language-javascript"><code>setInterval(() =&gt; {
  console.log('Hi');
}, 2000); 
// After every 2 seconds it logs:
// Hi
// Hi
// ....</code></pre>
<p>In most situations, it is important to stop calling the functions passed to the setInterval.</p>
<p>Similar to the <code>setTimeout</code>, <code>setInterval</code> returns an interval ID that uniquely identifies the interval(nothing but the <code>setInterval</code> instance).</p>
<p>Similar to <code>clearTimeout</code>, setInterval has <code>clearInterval</code>, calling it with the interval ID will clear or stop the setInterval instance from further calling the passed function.</p>
<pre class="language-javascript"><code>const intervalId = setInterval(() =&gt; {
  console.log('Hi');
}, 2000);

setTimeout(() =&gt; clearInterval(intervalId), 5000);
// Hi
// Hi
// By 5th second clearInterval stops the setInterval instance</code></pre>
<p>Just like in <code>setTimeout</code> we can pass the arguments to the function we want to call in setInterval after the delay argument.</p>
<pre class="language-javascript"><code>const greet = (name) =&gt; {
  console.log(`Hi, ${name}`);
}
const intervalId = setInterval(greet, 2000, 'John');
setTimeout(() =&gt; clearInterval(intervalId), 5000);
// Hi, John
// Hi, John</code></pre>
<p>So all the points that we discussed in the <code>setTimeout</code> section will hold true for the <code>setInterval</code>.&nbsp;</p>
<p><code>setTimeout</code> is also asynchronous, function reference has to be passed as the first argument instead of calling it and <code>this</code> keyword will not behave as expected similar to the <code>setTimeout</code>, so prefer using arrow functions.&nbsp;</p>
<p>So that's all you need to know about <code>setInterval</code> method in Javascript.</p>
<p>Let's see how we can create setInterval using setTimeout.</p>
<h2 id="nested-settimeout" style="text-align: center;">Nested setTimeout</h2>
<p>We can use <code>setTimeout</code> to create a <code>setInterval</code> like method with variable delays. Nested &nbsp;<code>setTimeout</code> in fact helps to set precise delays between function executions than <code>setInterval</code>.&nbsp;</p>
<p>Let's see an example to create a <code>setInterval</code> like method using nested setTimeouts.</p>
<pre class="language-javascript"><code>// const timer = setInterval(() =&gt; console.log('Hi'), 100); // Hi, Hi,...

//setInterval equivalent using nested setTimeout

let delay = 100;
let timerId = setTimeout(function greet() {
  console.log('Hi');
  // delay can be varied as per our requirements
  // if(condition) delay = ...;
  timerId = setTimeout(greet, delay);
}, delay);

// Logs after every 100 milliseconds
// Hi
// Hi
// ...</code></pre>
<p>If you try to experiment using setInterval and nested setTimeout, setInterval delays are not precise because it consumes some of the interval time in function execution and if the function execution takes more time than the delay, then you won't even see time delays between each function execution.</p>
<p>So for precise intervals between each function call, you should prefer using nested <code>setTimeout</code> over <code>setInterval</code>.</p>
<p>You should also keep in mind that, <code>setTimeout</code> and <code>setTimeout</code> do not guarantee exact time delays. The delays depend on CPU overload, background running processes in the browser window, etc.&nbsp;</p>
<p>And that is all about Javascript setTimeout and setInterval.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Guide to install yarn and essential yarn commands to know]]></title>
            <link>https://devapt.com/yarn-essential-commands</link>
            <guid isPermaLink="false">https://devapt.com/yarn-essential-commands</guid>
            <pubDate>Tue, 04 Jan 2022 08:45:03 GMT</pubDate>
            <description><![CDATA[Here is the guide to install yarn and all the essential yarn commands to know to get started with yarn effectively. Yarn provides speed and consistency.]]></description>
            <content:encoded><![CDATA[<p><code>yarn</code> is an alternative package manager for Javascript and the Javascript runtime environment(Node) which claims to provide speed, consistency, stability, and security.&nbsp;</p>
<p><code>yarn</code> was created in order to overcome some of the problems faced in dealing with packages for large codebases by Facebook in collaboration with Google and a few other companies.&nbsp;</p>
<p>Yarn stands for <strong>Yet Another Resource Negotiator</strong>.</p>
<h2 id="how-to-install-yarn" style="text-align: center;">How to install yarn?</h2>
<p>Yarn can be installed in various methods based on your operating system. With yarn version 2, a lot of things have changed compared to v1. But as of now installing process remains the same and to even use v2, we need to first install the latest v1.&nbsp;</p>
<h3 id="install-yarn-using-npm">Install yarn using npm&nbsp;</h3>
<p>Yes, using npm we can install yarn as a global package, for this, you need to have npm already installed. This works for all types of operating systems.</p>
<pre class="language-bash"><code>npm install -g yarn</code></pre>
<p>If you face any issues with installation or running yarn installed using npm, then you can follow up the OS-specific method for installing yarn.</p>
<h3 id="yarn-installation-for-mac-users">Yarn installation for Mac users</h3>
<p>Mac users can use homebrew for installing the yarn package manager.</p>
<pre class="language-bash"><code>brew install yarn</code></pre>
<p>For other ways of installation, you can visit this yarn official <a href="https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable" target="_blank" rel="noopener">link</a> and under alternatives dropdown select macOS and you'll see different ways of installing yarn in mac.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://res.cloudinary.com/cloudtale/image/upload/v1641227823/devapt/yarn-macos.jpg" alt="yarn-install-macos" width="450" /></p>
<h3 id="yarn-installation-for-windows-users">Yarn installation for Windows users</h3>
<p>Windows users can download the latest yarn <code>.msi</code> file from this <a href="https://classic.yarnpkg.com/lang/en/docs/install/#windows-stable" target="_blank" rel="noopener">link</a> and run it for installing the yarn. By using chocolatey and scoop package managers also yarn can be installed.</p>
<p>After the installation is completed you can confirm it by running the below command</p>
<pre class="language-bash"><code>yarn --version</code></pre>
<p>If you see the version number without any errors then you've successfully installed yarn.</p>
<p><code>yarn</code> is a CLI tool using which we can manage the packages from the npm registry.</p>
<p>Let's see the different yarn commands to manage npmjs packages.</p>
<p>There are a lot of yarn commands for dealing with npm packages but our main focus will be on the commands related to consuming the packages not creating or publishing those.</p>
<p>Note: We'll be seeing all commands from yarn v1 and a few updated commands of v2.</p>
<h2 id="essential-yarn-commands" style="text-align: center;">Essential yarn commands</h2>
<h3 id="to-check-the-yarn-version">To check the yarn version</h3>
<pre class="language-javascript"><code>yarn --version(or -v) // To see your yarn version</code></pre>
<h3 id="to-initialize">To initialize</h3>
<pre class="language-javascript"><code>yarn init
or 
yarn init -y // To autocomplete the details</code></pre>
<h3 id="for-installing-packages">For installing packages</h3>
<pre class="language-javascript"><code>yarn add  &lt;package&gt; // To save in dependencies list
yarn add --dev(or -D) &lt;package&gt; // To save in dev dependencies list

// To install a particular version of the package
yarn add &lt;package&gt;@2.1.1 // version as per the need, 2.1.1 is a sample version

// To install all the packages from package.json
yarn 
or
yarn install

// To install a global package accessible to all the projects
yarn global add &lt;package&gt;</code></pre>
<h3 id="for-listing-or-checking-packages">For listing or checking packages</h3>
<pre class="language-javascript"><code>yarn list // By default lists all the packages and their dependencies
yarn list --depth=0 // To restrict the depth of the dependencies use depth flag

// To list global packages just use global before list command
yarn global list // Lists all globally installed packages and their dependencies
yarn global list --depth=0 // Lists all global packages with zero level dependencies
</code></pre>
<h3 id="for-updating-packages">For updating packages</h3>
<pre class="language-javascript"><code>// For updating a single package (semver contraints will be respected)
yarn upgrade &lt;package&gt; // Updates package to the latest version in the current project
yarn global upgrade &lt;package&gt; // Updates global package to the latest version

// For updating all packages
yarn upgrade  // Updates all packages to their latest versions respecting their semver constraints
yarn global upgrade // Updates all global packages to their latest versions respecting semver constraints

// To check the outdated packages instead of directly updating
yarn outdated // Lists the outdated packages in the current project directory
yarn upgrade-interactive // Before updating the packages it shows a list of outdated packages to select

// To manually update any package to any version
yarn upgrade &lt;package&gt;@version
yarn global upgrade &lt;package&gt;@version</code></pre>
<p>Semver means <strong>semantic versioning</strong>. For the dependencies in the package.json, besides version number, a small hat(<code>^</code>) or tilde(<code>~</code>) is prefixed for some dependencies. It means those dependencies can be updated to the latest minor version when it is prefixed with (<code>^</code>) and to the latest patch version when it is prefixed with (<code>~</code>).&nbsp;</p>
<p>So <code>yarn upgrade</code> command when updating such dependencies considers semver prefixes without breaking the project or that dependency.&nbsp;</p>
<p>There's a whole site dedicated for <a href="https://semver.org/" target="_blank" rel="noopener">semver</a> to learn more about it.</p>
<h3 id="for-uninstalling-packages">For uninstalling packages</h3>
<pre class="language-javascript"><code>yarn remove &lt;package&gt; // To uninstall the package installed locally
yarn global remove &lt;package&gt; // To uninstall the globally installed package
</code></pre>
<h3 id="for-getting-package-details">For getting package details</h3>
<pre class="language-javascript"><code>yarn info &lt;package&gt; // Shows details about that particular package 
yarn info &lt;package&gt;@version // To see specific package version details
// To see the details of the package it need not be installed locally
</code></pre>
<h3 id="for-auditing-packages">For auditing packages</h3>
<pre class="language-javascript"><code>yarn audit // To scan all dependencies and list all the vulnerabilities 
yarn audit --json // To audit and list the details in a JSON format</code></pre>
<h3 id="miscellaneous-commands">Miscellaneous commands</h3>
<pre class="language-javascript"><code>yarn run &lt;command&gt; // Any script/command listed in the scripts in package.json
yarn run // Lists all the scripts available to run
yarn import // To generate yarn.lock from an npm package-lock.json while migration
</code></pre>
<p>Note all the commands are as per yarn v1 and in v2 lot of new commands are added. Once everyone starts using v2, these commands will be updated.&nbsp;</p>
<p>So that is all about the most important yarn commands to know for getting started using the yarn package manager.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[What is a JavaScript map? Difference b/w JS map & weakmap]]></title>
            <link>https://devapt.com/javascript-map</link>
            <guid isPermaLink="false">https://devapt.com/javascript-map</guid>
            <pubDate>Mon, 03 Jan 2022 08:44:48 GMT</pubDate>
            <description><![CDATA[Javascript map is a collection of key-value pairs of any data type. Learn more about JS maps, their methods and differences between maps and weakmaps.]]></description>
            <content:encoded><![CDATA[<p>A Javascript map object is a collection of key-value pairs where <strong>keys and objects can be of any data type </strong>including objects, functions, &amp; primitive types, unlike the objects, created using <code>{}</code> should have only a string or a symbol as a key. The map data type was added in the EcmaScript version 6(ES6).&nbsp;</p>
<p>To create a JS map, <code>Map</code> constructor is used. We can optionally pass an array of iterable objects to the <code>Map</code> to add the key-value pairs of that iterable object to the map.</p>
<pre class="language-javascript"><code>const items = new Map([iterable]);</code></pre>
<p>We can add key-value pairs to the map with the help of <code>set</code> method.</p>
<pre class="language-javascript"><code>const person = new Map();
person.set('name', 'John');
person.set('age', 25);

console.log(person.size); // 2</code></pre>
<p>A <code>Map</code> instance has got various methods for reading and manipulating the elements(key-value pairs) in it. It's an iterable and so by using iterative methods or loops we can read the data.&nbsp;</p>
<p>The various methods that we can use on maps are:</p>
<ul>
<li><code>set()</code> - to add key-value pairs to the map</li>
<li><code>get()</code> - to get the value of the key if it exists</li>
<li><code>has()</code> - to check if the key exists in the map, returns a boolean</li>
<li><code>delete()</code> - to delete the map element specified by the key</li>
<li><code>clear()</code> - to clear/delete all the elements of the map</li>
<li><code>keys()</code> - to get the iterator object of all keys in the map</li>
<li><code>values()</code> - to get the iterator object of all values in the map</li>
<li><code>entries()</code> - to get an iterator object with [key, value] elements&nbsp;</li>
<li><code>forEach()</code> - to call/invoke a callback function on every element in a map</li>
<li><code>size</code> - to get the total number of elements in a map</li>
</ul>
<p>Let's understand each method with examples</p>
<h2 id="javascript-map-methods" style="text-align: center;">Javascript map methods</h2>
<h3 id="set-method">set() method</h3>
<pre class="language-javascript"><code>const items = new Map(); // Initializing empty map
const john = { name: 'John', age: 25};
items.set(john, 'person'); // object as a key
items.set(1, 'number'); // number as a key
items.set(true, 'boolean'); // boolean as a key
items.set('color', 'red');

console.log(items.size); // 4</code></pre>
<p>We can see from the above that having any type of data type as the key is the specialty of javascript map objects. If it's a normal object then the keys get converted to strings or object strings.</p>
<p>As we know that the instance of <code>Map</code> returns an iterable, so we can use <a href="https://devapt.com/for-loops-javascript" target="_blank" rel="noopener">for-of loop</a> to read the values of an iterable just like in <a href="https://devapt.com/javascript-set-weakset" target="_blank" rel="noopener">JS sets</a>.&nbsp;</p>
<pre class="language-javascript"><code>// Iterating from the previous map object
for(const item of items) {
  console.log(item);
}
// Logs:
// [{name: "John"}, "person"]
// [1, "number"]
// [true, "boolean"]
// ["color", "red"]</code></pre>
<h3 id="get-method">get() method</h3>
<pre class="language-javascript"><code>const letters = new Map([['a', 1], ['b', 2], [3, 'c'], [4, 'd']]);
letters.get('a'); // 1
letters.get(4); // d</code></pre>
<h3 id="has-method">has() method</h3>
<pre class="language-javascript"><code>const letters = new Map([['a', 1], ['b', 2], [3, 'c'], [4, 'd']]);

// Checks if the key exists in the map element and returns a boolean
letters.has(5); // false
letters.has(4); // true</code></pre>
<h3 id="delete-method">delete() method</h3>
<pre class="language-javascript"><code>const letters = new Map([['a', 1], ['b', 2], [3, 'c'], [4, 'd']]);

// Deletes the map element if the given key exists
letters.delete('b');
console.log(letters.size); // 3
</code></pre>
<h3 id="clear-method">clear() method</h3>
<pre class="language-javascript"><code>const letters = new Map([['a', 1], ['b', 2], [3, 'c'], [4, 'd']]);

// Clears or deletes all the elements in the map
letters.clear();
console.log(letters.size); // 0</code></pre>
<h3 id="keys-method">keys() method</h3>
<pre class="language-javascript"><code>const letters = new Map([['a', 1], ['b', 2], [3, 'c'], [4, 'd']]);

// map.key() method returns key of every map element
for(const key of letters.keys()) {
  console.log(key);
}
// Logs: a, b, 3, 4</code></pre>
<h3 id="values-method">values() method</h3>
<pre class="language-javascript"><code>const letters = new Map([['a', 1], ['b', 2], [3, 'c'], [4, 'd']]);

// map.values() returns the value of each map element
for(const value of letters.values()) {
  console.log(value);
}
// Logs: 1, 2, c, d</code></pre>
<h3 id="entries-method">entries() method</h3>
<p>The&nbsp; <code>entries()</code> method is similar to the <code>Object.entries()</code>, where it returns keys and values of an object as an array of <code>[key, value]</code> arrays. Similarly in the case of map <code>entries()</code> method, an iterator with <code>[key, value]</code> arrays is returned for every element in the map, instead of an array.</p>
<pre class="language-javascript"><code>const letters = new Map([['a', 1], ['b', 2], [3, 'c'], [4, 'd']]);

for(const letter of letters.entries()) {
  console.log(letter);
}

// Logs: ["a", 1], ["b", 2], [3, "c"], [4, "d"]</code></pre>
<h3 id="foreach-method">forEach() method</h3>
<p>The map <code>forEach</code> method works the same as the <code>forEach</code> method on arrays. It allows running a callback function on every element of the map. The first two arguments of the callback function gives value and key of the current element.&nbsp; &nbsp;</p>
<pre class="language-javascript"><code>const letters = new Map([['a', 1], ['b', 2], [3, 'c'], [4, 'd']]);

letters.forEach((value, key) =&gt; console.log(key, value));
// Logs: a 1, b 2, 3 c, 4 d</code></pre>
<h3 id="size-property">size property</h3>
<p>The size property of a <code>Map</code> instance returns the total number of elements(key-value pairs) present in the map, nothing but the length of the map. This property is not available on a normal object created using <code>{}</code>.</p>
<pre class="language-javascript"><code>const letters = new Map([['a', 1], ['b', 2], [3, 'c'], [4, 'd']]);

console.log(letters.size); // 4</code></pre>
<p>So far we've seen different ways to iterate the map object. Let's see all together once.</p>
<h2 id="different-ways-to-iterate-maps" style="text-align: center;">Different ways to iterate maps</h2>
<pre class="language-javascript"><code>const letters = new Map([['a', 1], ['b', 2], [3, 'c'], [4, 'd']]);

for(const [key, value] of letters) console.log(key, value); 
for(const [key, value] of letters.entries()) console.log(key, value);
letters.forEach((value, key) =&gt; console.log(key, value)); 
// Above three iterations log the same result

for(const key of letters.keys()) console.log(key); // Logs: keys 
for(const value of letters.values()) console.log(value); // Logs: values</code></pre>
<h2 id="js-maps-from-js-objects" style="text-align: center;">JS maps from JS objects</h2>
<p>A JS map can be created from JS objects by converting them to arrays and vice versa.</p>
<pre class="language-javascript"><code>// From object to map
const obj = {
  a: 1, 
  b: 2, 
  c: 3, 
  d: 4
}
const mapObj = new Map(Object.entries(obj));
for(const element of mapObj) console.log(element); 
// Logs: ["a", 1], ["b", 2], ["c", 3], ["d", 4]

// From map to object
const objFromMap = Object.fromEntries(mapObj);
console.log(objFromMap); 
// Logs: {a: 1, b: 2, c: 3, d: 4}</code></pre>
<h2 id="when-and-where-to-use-js-map-object" style="text-align: center;">When and where to use JS map object?</h2>
<p>A map is a collection of elements(key-value pairs) and the elements can be iterated in the order of their insertion.</p>
<h3 id="a-map-can-be-used">A map can be used</h3>
<h4>1. To preserve the order of the key-value pairs</h4>
<p>The order of the key-value pairs is not guaranteed in the object created using <code>{}</code> but javscript map object has definite order of the insertion of elements.&nbsp;</p>
<h4>2. To get good performance in frequent addition and removal of key-value pairs</h4>
<p>Objects created using <code>{}</code> or <code>Object</code> are not optimized for frequent addition and deletion of key-value pairs. So in such cases using JS maps can give good performance.</p>
<p>There's a special case of JS maps called WeakMap, let's have a glimpse at it.</p>
<h2 id="what-is-a-weak-map-in-javascript" style="text-align: center;">What is a weak map in Javascript?</h2>
<p>A weakmap is similar to the map in Javascript but with limitations on the key data types and the methods, it can have.</p>
<p>Unlike map, weakmap can contain only the objects as keys and values can be of any data type. And only <code>set()</code>, <code>get()</code>, <code>has()</code>, <code>delete()</code> methods are available on a <code>WeakMap</code> instance. No iterative methods can be applied on weak maps, including, <code>forEach</code> etc.</p>
<pre class="language-javascript"><code>const colors = new WeakMap();
const green = { name: 'green'};
const greenHex = { hex: '#00FF00'}
const red = { name: 'red'};
colors.set(green, greenHex);
colors.set(red, '#FF0000');
console.log(colors.has(red)); // true
colors.delete(red);
console.log(colors.has(red)); // false

// Try adding a string key or any other data type except object to the weakmap
colors.set('blue', '#0000FF'); // Throws an error
</code></pre>
<blockquote>
<p>A weakmap is called so because of the weak references to the data(objects) it contains. When the reference to the objects is lost, they get garbage collected.</p>
</blockquote>
<pre class="language-javascript"><code>let a = { index: 1 };
let b = { index: 2 };

const wMap = new WeakMap();

wMap.set(a, 'one');
wMap.set(b, 'two');
console.log(wMap.has(a)); // true
console.log(wMap.has(b)); // true
a = null; // removing the reference for { index: 1 } 
console.log(wMap.has(a)); // false</code></pre>
<p>WeakMap, similar to WeakSet is mainly used as additional storage of data for objects that are stored or managed from another location.&nbsp;</p>
<p>That was a quick look at weak maps and overall the maps in Javascript.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[What is a JavaScript Set? When and where to use JS sets?]]></title>
            <link>https://devapt.com/javascript-set-weakset</link>
            <guid isPermaLink="false">https://devapt.com/javascript-set-weakset</guid>
            <pubDate>Fri, 31 Dec 2021 09:00:46 GMT</pubDate>
            <description><![CDATA[A Javascript set is a collection of unique unordered elements of any data type. Here are all the methods and uses of sets in Javascript.]]></description>
            <content:encoded><![CDATA[<p>A set in JavaScript is a collection of unique values of any data type. The set data type was added in the EcmaScript version 6(ES6).&nbsp;</p>
<p>To create a JS set, <code>Set</code> constructor is used. We can optionally pass an iterable object to the <code>Set</code> to add the elements of that iterable(often an array) object to the set.</p>
<pre class="language-javascript"><code>const names = new Set(['John', 'Doe', 'Mary', 'Alice']);
console.log(names.size); // 4</code></pre>
<p>We can add elements to the set with the help of <code>add</code> method.</p>
<pre class="language-javascript"><code>const cities = new Set();
cities.add('Rome');
cities.add('Tokyo');
console.log(cities.size); // 2</code></pre>
<p>The reason why we're just logging or printing the size of the sets is that we may not see the elements of the set just by logging directly. When we try to log it on the console, we could just see something like <code>Set {}</code> or <code>[object Set] { ... }</code> etc based on the environment.</p>
<p>A <code>Set</code> instance has got various methods for reading and manipulating the data inside it. It's an iterable and so by using iterative methods or loops we can read the data.&nbsp;</p>
<p>The various methods that we can use on sets are:</p>
<ul>
<li><code>add()</code> - to add elements to the set</li>
<li><code>has()</code> - to check if the set has a particular element</li>
<li><code>delete()</code> - to delete the element if it exists</li>
<li><code>clear()</code> - to clear/delete all the elements of the set</li>
<li><code>values()</code> - to get the iterator of values inside the set</li>
<li><code>keys()</code> - same as values(). It is there just to match the methods with the map data type</li>
<li><code>entries()</code> - to get an iterator with [key, value] elements and in a set keys and values are the same. It also exists to match with the methods of the map data type</li>
<li><code>forEach()</code> - to call/invoke a callback function on every element in a set</li>
<li><code>size</code> - to get the total number of elements in a set</li>
</ul>
<p>Let's understand each method with examples</p>
<h2 id="javascript-set-methods" style="text-align: center;">Javascript set methods</h2>
<h3 id="add-method">add() method</h3>
<pre class="language-javascript"><code>const colors = new Set(); // Initializing an empty set
colors.add('green');
colors.add('blue');
colors.add('red');
console.log(colors.size); // 3</code></pre>
<p>As we know that instance of <code>Set</code> returns an iterable, so we can use <a href="https://devapt.com/for-loops-javascript" target="_blank" rel="noopener">for-of loop</a> as discussed in the previous article to read the values of an iterable.&nbsp;</p>
<pre class="language-javascript"><code>for(const color of colors) {
  console.log(color)
}
// Logs: green, blue, red</code></pre>
<h3 id="has-method">has() method</h3>
<pre class="language-javascript"><code>const colors = new Set('green', 'blue', 'red');

// Checks if the elements exists in the set and returns a boolean
colors.has('red'); // true
colors.has('violet'); // false</code></pre>
<h3 id="delete-method">delete() method</h3>
<pre class="language-javascript"><code>const colors = new Set(['green', 'blue', 'red']);

// Deletes the exact given element if it exists
colors.delete('red');
console.log(colors.size); // 2</code></pre>
<h3 id="clear-method">clear() method</h3>
<pre class="language-javascript"><code>const colors = new Set(['green', 'blue', 'red']);

// Clears or deletes all the elements in a set
colors.clear();
console.log(colors.size); // 0</code></pre>
<h3 id="values-and-keys">values() and keys()</h3>
<p>In the case of a JS set, <code>keys()</code> and <code>values()</code> methods return the same kind of iterator for iterating the values in a set. The main reason for having <code>keys()</code> method is to have similar methods as that of a <code>Map</code> data type in Javascript.</p>
<pre class="language-javascript"><code>const colors = new Set(['green', 'blue', 'red']);

// values() and keys() return the same
for(const color of colors.values()) {
  console.log(color)
}
// Logs: green, blue, red

for(const color of colors.keys()) {
  console.log(color)
}
// Logs: green, blue, red</code></pre>
<h3 id="entries-method">entries() method</h3>
<p>The set <code>entries()</code> method is similar to the <code>Object.entries()</code>, where it returns keys and values of an object as an array of arrays. In the case of set <code>entries()</code> method, an iterator with <code>[key, value]</code> arrays is returned where keys and values are the same.&nbsp;</p>
<blockquote>
<p><code>Object.entries(object)</code> returns an actual array of arrays but <code>set.entries()</code> returns an iterator with [key, value] arrays.</p>
</blockquote>
<pre class="language-javascript"><code>const colors = new Set(['green', 'blue', 'red']);

for(const color of colors.entries()) {
  console.log(color)
}
// Logs: ["green", "green"], ["blue", "blue"], ["red", "red"]
</code></pre>
<h3 id="foreach-method">forEach() method</h3>
<p>The set <code>forEach</code> method works the same as the <code>forEach</code> method on arrays. It allows running a callback function on every element of the set.</p>
<pre class="language-javascript"><code>const colors = new Set(['green', 'blue', 'red']);

colors.forEach(c =&gt; console.log(c));
// Logs: green, blue, red</code></pre>
<h3 id="size-property">size property</h3>
<p>The size property of a <code>Set</code> instance returns the total number of elements present inside the set, nothing but the length of the set.&nbsp;</p>
<pre class="language-javascript"><code>const colors = new Set(['green', 'blue', 'red']);
console.log(colors.size); // 3</code></pre>
<p>So far we've seen different ways to iterate the sets. Let's see all together once.</p>
<h2 id="different-ways-to-iterate-sets" style="text-align: center;">Different ways to iterate sets</h2>
<pre class="language-javascript"><code>// All these iterations return the same result
const cities = new Set(['Tokyo', 'Seoul', 'Rio', 'Delhi']);

for (const city of cities) console.log(city);
for (const city of cities.keys()) console.log(city);
for (const city of cities.values()) console.log(city);
for (const [key, value] of cities.entries()) console.log(key);
cities.forEach((c) =&gt; console.log(c));

// Converting javascript set to array 
Array.from(cities).forEach((c) =&gt; console.log(c);

// Each iteration logs: Tokyo, Seoul, Rio, Delhi

</code></pre>
<h2 id="when-and-where-to-use-js-set" style="text-align: center;">When and where to use JS set?</h2>
<p>A set is a collection of unique unordered elements and the elements can be iterated in the order of their insertion.</p>
<h3 id="a-set-can-be-used">A set can be used</h3>
<h4>1. To remove the duplicates in an array</h4>
<pre class="language-javascript"><code>const letters = ['a', 'b', 'c', 'b', 'a', 'd']; // An array with duplicate letters
const uniqueLetters = [...new Set(letters)]; // Spreading the set created from the letters array
console.log(uniqueLetters); 
// Logs: ["a", "b", "c", "d"]</code></pre>
<h4>2. To find if an element exists in an array effectively</h4>
<p>Finding the existence of an element in an array of very large size may have performance problems. In such a case, <code>set.has()</code> method could be handy. <code>set.has()</code> has a time complexity of O(1) but it seems to be not guaranteed in all the situations. Learn more about it <a href="https://stackoverflow.com/questions/31091772/javascript-es6-computational-time-complexity-of-collections" target="_blank" rel="noopener">here</a>.</p>
<p><code>set.has()</code> method works very effectively compared to array methods for checking the existence of an element in a large array.</p>
<pre class="language-javascript"><code>const letters = ['a', 'b', 'c', ..., 'z']; // say a very large array 

// indexOf() and findIndex() may have performance issues
letters.indexOf('z'); // letters.length - 1
letters.findIndex(l =&gt; l === 'z'); // letters.length - 1

// Converting to a set and finding the existence 
const letterSet = new Set(letters);
console.log(letterSet.has('z')); // true</code></pre>
<p>There's a special case of JS sets called WeakSet, let's have a glimpse at it.</p>
<h2 id="what-is-a-weak-set-in-javascript" style="text-align: center;">What is a weak set in Javascript?</h2>
<p>A weakset is similar to a set in Javascript but with limitations on the data types it can store and the methods it can have.</p>
<p>Unlike set, weakset can contain only the objects. And only <code>add()</code>, <code>has()</code>, <code>delete()</code> methods are available on a <code>WeakSet</code> instance. No iterative methods can be applied on weak sets, can't even check the size of a weakset.</p>
<pre class="language-javascript"><code>const colors = new WeakSet();
const green = { name: 'green' };
const red = { name: 'red' };
colors.add(green);
colors.add(red);
colors.has(green); // true
colors.delete(red);
colors.has('red'); // false

// Try adding a string or any other data type except object to the weakset
colors.add('violet'); // Throws an error</code></pre>
<blockquote>
<p>A weakset is called so because of the weak references to the data(objects) it contains. When the reference to the objects is lost, they get garbage collected.</p>
</blockquote>
<pre class="language-javascript"><code>let a = { index: 1 };
let b = { index: 2 };

const wSet = new WeakSet();

wSet.add(a);
wSet.add(b);
console.log(wSet.has(a)); // true
console.log(wSet.has(b)); // true
a = null; // removing the reference for { index: 1 } 
console.log(wSet.has(a)); // false</code></pre>
<p>WeakSet is mainly used as additional storage of data for objects that are stored or managed from another location.&nbsp;</p>
<p>That was a quick look at weaksets and overall the sets in Javascript.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[JavaScript for loops, their uses & trick to remember each]]></title>
            <link>https://devapt.com/for-loops-javascript</link>
            <guid isPermaLink="false">https://devapt.com/for-loops-javascript</guid>
            <pubDate>Thu, 30 Dec 2021 09:00:59 GMT</pubDate>
            <description><![CDATA[Here are all the details you need to know about JavaScript for loops and their differences. How forEach is different compared to other for-loops?]]></description>
            <content:encoded><![CDATA[<p>In programming, the concept of looping is seen to repeat a block of code without actually writing it multiple times and to make it look compact and readable. The concept of implementing a loop remains similar in most programming languages.&nbsp;</p>
<p>In Javascript, we have quite different ways to implement loops. In this article, we are going to look at the three kinds of Javascript for loops viz., <code>for</code>, <code>for in</code> and <code>for of</code>. Besides <code>for</code> loops there are <code>while</code>, <code>do while</code> and different iterative methods that can be called on arrays to perform looping actions.</p>
<h2 id="for-loops-in-javascript" style="text-align: center;">For loops in Javascript</h2>
<h3 id="js-for-loop">JS for loop</h3>
<p>The for loop in JS is similar to the C language for loop, it takes three statements, first is initialization, second is condition and third is the update.&nbsp;</p>
<pre class="language-javascript"><code>for (Statement 1; Statement 2; Statement 3) {
  // code block
}</code></pre>
<ul>
<li>Statement 1: Initialization of the variable is done using <code>let</code> or <code>var</code> keywords. <code>const</code> cannot be used because variables declared with <code>const</code> cannot be reassigned.&nbsp;</li>
<li>Statement 2: Condition for ending the loop</li>
<li>Statement 3: For updating the value of the variable</li>
</ul>
<pre class="language-javascript"><code>// A simple for loop to log numbers from 0 to 9
for( let i = 0; i &lt; 10; i++) {
  console.log(i);
}</code></pre>
<p>The first and the third statements can be omitted if those are defined in other parts of the code, but the second statement is important for ending the loop. If the second statement returns true then the loop keeps running if it's false, it stops. When the second statement is also omitted, care has to be taken to break the loop from inside.&nbsp;</p>
<pre class="language-javascript"><code>// First and third statements are omitted but are inferred one from outside and the other inside the loop
let i = 0;
for (; i &lt; 5; ) {
  console.log(`Logging ${i}`);
  i++;
}
</code></pre>
<p>Using <code>let</code> keyword for <code>for loop</code> doesn't affect the variables declared outside the loop because of the block scope but if <code>var</code>&nbsp;keyword is used for <code>for loop</code> then it may overwrite the values outside the scope.</p>
<pre class="language-javascript"><code>let i = 5;
for (let i = 0; i &lt; 10; i++) {
  // some code block
}
console.log(i); // The value of i is 5</code></pre>
<pre class="language-javascript"><code>var i = 5;
for (var i = 0; i &lt; 10; i++) {
  // some code block
}
console.log(i); // 10
// It is 10 because the value of i when loop ends is 10 
// and it is declared with var, so the value persists outside the block</code></pre>
<p>Next, let's see the for-in loop.</p>
<h3 id="js-for-in-loop">JS for-in loop</h3>
<p>The Javascript for-in loop is used to iterate over the properties of an object especially the enumerable properties of the object.&nbsp;</p>
<blockquote>
<p>Enumerable properties are those that have enumerable flag set to true when defining the property. By default objects created using <code>{}</code> are enumerable. Find more about it on <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties" target="_blank" rel="noopener">mozilla</a>.</p>
</blockquote>
<pre class="language-javascript"><code>// for-in loop
for( let key in object) {
  // key gives each key in the object for every iteration
  // code block
}</code></pre>
<pre class="language-javascript"><code>const countries = {
  norway: 'oslo',
  japan: 'tokyo',
  finland: 'helsinki'
}

// const can be used because it's not being reassigned
for(const country in countries) {
  console.log(countries[country]);
}

// Logs all the values assigned to each country</code></pre>
<p>The for-in loop can also be used for arrays and strings just like objects because the keys for arrays or strings will simply be their indexes. The caveat for using for-in for arrays is that the order of indexes may not be right all the time because those will be treated like the keys in an object and so in the object, the order of the keys is not guaranteed.</p>
<pre class="language-javascript"><code>const numbers = [10, 9, 8, 7, 6];

for(const index in numbers) {
  console.log(numbers[index])
}

// Index order may not be right all the time
// To understand this, conceive it like an object, 
// where the order of props is not guaranteed
// {
//   '0': 10,
//   '1': 9,
//   '2': 8,
//   '3': 7,
//   '4': 6,
// }</code></pre>
<h3 id="js-for-of-loop">JS for-of loop</h3>
<p>The Javascript <code>for-of loop</code> loops over the values of the iterable object. The iterable here cannot be a direct object with key-value pairs because we can't access values directly without their keys. So the iterable in <code>for-of</code> loop refers to an array-like object or a string.</p>
<pre class="language-javascript"><code>// for-of loop
for( let value of iterable) {
  // value gives each value in the iterable
  // code block
}</code></pre>
<pre class="language-javascript"><code>const colors  = ['red', 'green', 'pink', 'yellow'];

for(const color of colors) {
  console.log(color); 
}
// All the values from the colors array get logged
</code></pre>
<p>Using for-of we can iterate over the letters of a string easily.</p>
<pre class="language-javascript"><code>const name = 'John';
for(const letter of name) {
  console.log(letter);
}
// Each letter of the string name gets logged</code></pre>
<p>To access the key-value pairs of an object using <code>for-of</code> loop we can use <code>Object.entries</code> method.</p>
<pre class="language-javascript"><code>const countries = {
  norway: 'oslo',
  japan: 'tokyo',
  finland: 'helsinki',
};

for (const [country, capital] of Object.entries(countries)) {
  console.log(country + ' - ' + capital);
}
// norway - oslo
// japan - tokyo
// finland - helsinki</code></pre>
<p>So that is about for-of loop.</p>
<p>People often get confused in remembering the Javascript for-in and for-of loops.</p>
<p>A simple trick is whenever you see <code>for-in</code> loop think of the second word <code>in</code> as an index which means it can iterate over indexes of an array and the equivalent part in objects is keys.&nbsp;</p>
<p>In the case of <code>for-of</code> loop, think of <code>of</code> as value belonging to something, in objects values belong to keys, and in arrays just the values directly.</p>
<p>There's one more in Javascript for loops that starts with for, but it is a method that can be called on arrays. Let's have a glimpse at that.</p>
<h3 id="js-foreach-for-arrays">JS forEach for arrays</h3>
<p><code>forEach</code> is a method that can be run on arrays to iterate the values and indexes in their original order. This is the most often used method for looping arrays.&nbsp;</p>
<p><code>forEach</code> takes a callback function with three arguments(the last two are optional), that runs on every element of the array.</p>
<pre class="language-javascript"><code>array.forEach((value, index, array) =&gt; {
  // code block
})</code></pre>
<p><strong>Note: </strong><code>forEach</code> doesn't have support for async, await, the results could be not as expected when you await the results inside forEach method. Use <code>for</code>, <code>for-of</code> or <code>for-in</code> loops for asynchronous operations.</p>
<p>That's all about Javascript for-loops. Hope this gave a quick understanding of the differences between each.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Essential npm commands every JS developer should know]]></title>
            <link>https://devapt.com/npm-commands-list</link>
            <guid isPermaLink="false">https://devapt.com/npm-commands-list</guid>
            <pubDate>Wed, 29 Dec 2021 08:45:46 GMT</pubDate>
            <description><![CDATA[Here are all the essential npm commands you need to know to use the npm CLI effectively. You can search, update, view any package right from your CLI.]]></description>
            <content:encoded><![CDATA[<p><code>npm</code> is a package manager for Javascript and the Javascript runtime(Node). Often npm is considered as an acronym for Node Package Manager but in reality, it is not. <code>pm</code> in <code>npm</code> stands for <strong>pkgmakeinst</strong> as per the <a href="https://github.com/npm/cli#is-npm-an-acronym-for-node-package-manager" target="_blank" rel="noopener">npm docs</a>.</p>
<p>npm has a command-line client which is called npm CLI or just <code>npm</code>. npm comes installed with the Node. npmjs is the site where npm packages can be browsed and searched.&nbsp;</p>
<p>Here we are going to see the npm commands in CLI to install, update and manage various packages from the npm registry.</p>
<p>There are a lot of npm commands for dealing with npm packages but our main focus will be on the commands related to consuming the packages not creating or publishing those.</p>
<h2 id="essential-npm-commands" style="text-align: center;">Essential npm commands</h2>
<h3 id="to-check-the-npm-version">To check the npm version</h3>
<pre class="language-javascript"><code>npm --version(or -v) // To see your npm version</code></pre>
<h3 id="to-initialize">To initialize</h3>
<pre class="language-javascript"><code>npm init
or 
npm init -y // To autocomplete the details</code></pre>
<h3 id="for-installing-packages">For installing packages</h3>
<pre class="language-javascript"><code>npm i --save(or -S) &lt;package&gt; // To save in dependencies list
npm i --save-dev(or -D) &lt;package&gt; // To save in dev dependencies list

// Shorthand commands for the above
npm i &lt;package&gt; // By default packages get added to dependencies
npm i -D &lt;package&gt; // To add to dev dependencies

// To install a particular version of the package
npm i &lt;package&gt;@5.1.1 // version as per the need, 5.1.1 is a sample version

// To install all the packages from package.json
npm install 
or
npm i

// To install global package accessible to all the projects
npm install -g &lt;package&gt;
or 
npm i -g &lt;package&gt;</code></pre>
<h3 id="for-listing-or-checking-packages">For listing or checking packages</h3>
<pre class="language-javascript"><code>// From npm v7.x, list command by default lists only the installed package names, not their dependencies
npm list(or ls or la or ll) // Lists all the packages installed in the current project
npm list --all // Lists all the packages with dependencies in a tree structure

// To list global packages just use -g flag
npm list -g // Lists all globally installed packages
npm list -g --all // Lista all global packages with dependencies

// Shorthand for --all is -a
// ls, la, ll are all aliases for list, any of those shorthands can be used</code></pre>
<h3 id="for-updating-packages">For updating packages</h3>
<pre class="language-javascript"><code>// For updating a single package(semver contraints will be respected)
npm update &lt;package&gt; // Updates package to the latest version in the current project
npm update -g &lt;package&gt; // Updates global project to the latest version

// For updating all packages
npm update  // Updates all packages to their latest versions respecting their semver contraints
npm update -g // Updates all global packages to their latest versions respecting semver contraints

// Shorthand commands for the above
npm up &lt;package&gt;
npm up -g &lt;package&gt;
npm up
npm up -g

// To check the outdated packages instead of directly updating
npm outdated // Lists the outdated packages in the current project directory
npm -g outdated // Lists the outdated global packages

// To manually update any package to any version
npm i &lt;package&gt;@version
npm i -g &lt;package&gt;@version</code></pre>
<p>Semver means semantic versioning. For the dependencies in the package.json, besides version number, a small hat(^) or tilde(~) is prefixed for some dependencies. It means those dependencies can be updated to the latest minor version when it is prefixed with (^) and to the latest patch version when it is prefixed with (~).&nbsp;</p>
<p>So <code>npm up</code> command when updating such dependencies considers semver prefixes without breaking the project or that dependency.&nbsp;</p>
<p>There's a whole site dedicated for <a href="https://semver.org/" target="_blank" rel="noopener">semver</a> to learn more about it.</p>
<h3 id="for-uninstalling-packages">For uninstalling packages</h3>
<pre class="language-javascript"><code>npm uninstall &lt;package&gt; // To uninstall the current project package
npm uninstall -g &lt;package&gt; // To uninstall the globally installed package

// Shorthand commands for the above
npm un &lt;package&gt;
npm un -g &lt;package&gt;</code></pre>
<h3 id="for-viewing-package-details">For viewing package details</h3>
<pre class="language-javascript"><code>npm view &lt;package&gt; // Shows details about that particular package 
npm view -g &lt;package&gt; // To see details for the globally installed package

// info, show, v are the aliases for view
// To see particular version details use @version</code></pre>
<h3 id="for-searching-packages">For searching packages&nbsp;</h3>
<pre class="language-javascript"><code>npm search &lt;keyword(s)&gt; // List all the packages matching the keyword

// s, se, find are the aliases for search</code></pre>
<h3 id="for-auditing-packages">For auditing packages</h3>
<pre class="language-javascript"><code>npm audit // To scan project and list all the vulnerabilities without fixing anything
npm audit --json // To audit and list the details in a JSON format
npm audit fix // To scan the project for vulnerabilities and automatically install compatible updates to vulnerable dependencies
npm audit --dry-run --json // To get an idea of what audit fix will do, and output the information in JSON format</code></pre>
<h3 id="miscellaneous-commands">Miscellaneous commands</h3>
<pre class="language-javascript"><code>npm ci // To do a clean install by removing the existing node_modules
npm prune // To remove extraneous packages not listed on the parent package's dependencies list
npm start // To run the scripts mentioned with start key in the package.json scripts
npm run &lt;command&gt; // Any script/command listed in the scripts other than start
npm test // To run the test script if there's any
npx &lt;command&gt; // Used to run any command from npm package (from locally installed or remotely fetched)</code></pre>
<p>Note that npm version 7.x is considered when listing all the above commands. Certain commands may differ with lower or higher major versions.&nbsp;</p>
<p>So those are all the most essential npm commands every Javascript developer should know. A nice dedicated cheatsheet for the above commands will be released soon.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Native JavaScript popup boxes all you need to know]]></title>
            <link>https://devapt.com/javascript-popup-boxes</link>
            <guid isPermaLink="false">https://devapt.com/javascript-popup-boxes</guid>
            <pubDate>Tue, 28 Dec 2021 08:39:25 GMT</pubDate>
            <description><![CDATA[Here are the different JavaScript popup methods you should know and their use cases. Alert, Confirm, and Prompt can be used instantly to show messages.]]></description>
            <content:encoded><![CDATA[<p>Javascript has got three different inbuilt popup boxes to notify, confirm and take user input data. These popup boxes are very handy for prototyping, teaching, and accepting or printing out the data instantly without the need to create popups from scratch.&nbsp;</p>
<h2 id="javascript-popup-message-boxes" style="text-align: center;">JavaScript popup message boxes</h2>
<h4>The different Javascript popup boxes or methods are:</h4>
<ol>
<li>Alert</li>
<li>Confirm</li>
<li>Prompt</li>
</ol>
<h3 id="how-to-use-the-alert-box-in-js" style="text-align: center;">How to use the alert box in JS?</h3>
<p><code>alert</code> is a global method in Javascript which means we can use it in any part of our code. Often it is used with the window object <code>window.alert</code> but calling <code>alert</code> method directly without prefixing <code>window</code> means the same, as every window property and method can be accessed directly without the prefix.</p>
<pre class="language-javascript"><code>alert('Welcome to the DevApt');</code></pre>
<p>The <code>alert</code> method:</p>
<ul style="list-style-type: square;">
<li>takes an optional input as a message to display to the user.&nbsp;</li>
<li>prevents users from accessing other parts of the browser window until the alert box is closed</li>
<li>can run any valid Javascript code passed as an argument, which means you should never pass user entered data directly</li>
<li><strong>returns nothing or <code>undefined</code></strong></li>
</ul>
<p>Few examples of <code>alert</code> popup:</p>
<pre class="language-javascript"><code>alert(); // Shows empty dialog box
alert("Hi,\nYou clicked I'm feeling lucky button"); // Show the message in two lines
alert(2+2); // Calculates and shows 4
alert(localStorage.getItem('token')); // Show the value of 'token' if stored in local storage else null

const result = alert('Your form submitted');
console.log(result); // undefined</code></pre>
<h3 id="how-to-use-the-confirm-box-in-javascript" style="text-align: center;">How to use the confirm box in Javascript?</h3>
<p>Just like <code>alert</code>, <code>confirm</code> is also a global method that can be accessed in any part of the Javascript code. The main difference is that on popping out the alert it returns a boolean value, eithor true or false based on the user action.&nbsp;</p>
<pre class="language-javascript"><code>confirm('Do you want to leave the page without saving?');</code></pre>
<p>The <code>confirm</code> method:</p>
<ul style="list-style-type: square;">
<li>takes an optional input as a message to display it to the user for the confirmation</li>
<li>prevents users from accessing other parts of the browser window until the confirm box is closed</li>
<li>can run any valid Javascript code passed as an argument, which means you should never pass user entered data directly</li>
<li><strong>returns <code>true</code> when user clicks <code>OK</code> and <code>false</code> when user clicks <code>Cancel</code> button on the confirm box</strong></li>
</ul>
<p>Few examples of <code>confirm</code> popup:</p>
<pre class="language-javascript"><code>const result = confirm('Do you like to cancel the request?');
if(result) console.log('You request is cancelled');
else console.log('Your request is processing'); 

if(confirm("Is 2 + 2 = 4")) location.href = '/dashboard'; // If confirmed redirected to the /dashboard page</code></pre>
<h3 id="how-to-use-the-prompt-box-in-js" style="text-align: center;">How to use the prompt box in JS?</h3>
<p><code>prompt</code> is a global method similar to the <code>alert </code>and <code>confirm</code> popup methods. By using <code>alert</code> and <code>confirm</code> popup methods we cannot let the user enter/send the data, and to fulfil that case we have this <code>prompt</code> method. Whenever user enters any data in the popup box, the same gets returned on clicking the <code>OK</code> button else <code>null</code>.</p>
<pre class="language-javascript"><code>prompt('Enter your name');</code></pre>
<p>The <code>prompt</code> method:</p>
<ul style="list-style-type: square;">
<li>takes an optional input as a message to display the same to the user</li>
<li>prevents users from accessing other parts of the browser window until the prompt box is closed</li>
<li>can run any valid Javascript code passed as an argument, which means you should never pass user entered data directly</li>
<li><strong>returns user entered data as a string when user clicks <code>OK</code> and <code>null</code> when user clicks <code>Cancel</code> button on the prompt box</strong></li>
</ul>
<p>Few examples of <code>prompt</code> popup:</p>
<pre class="language-javascript"><code>const result = prompt("Enter something");
if(Boolean(result)) console.log(`You entered ${result}`); // Logs the input if user enters any data

const result = prompt('What is 2 + 2?');
if(Number(result) === 4) alert("You are right!");  // Shows an alert if it's 4
else alert('You are wrong!');  // Shows an alert for input or action other than 4</code></pre>
<p>There are few points to note before you use these popup methods in your code. These methods <em>should not be</em> used when you want to have a very good user experience.</p>
<p>The <code>alert</code> method has a history of being used in XSS(Cross Site Scripting) attacks, so you should never use <code>alert</code> method with user entered data directly.&nbsp;</p>
<p>The most general use of <code>alert</code> and <code>confirm</code> boxes is, when users are about to leave your site or when something is not saved or incomplete, showing these popups feels normal. Sites like Facebook uses this type of popup alert when you try to go back or leave the site in between uploading or publishing the post.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[How to use URL & URLSearchParams in JS to read and manipulate URLs]]></title>
            <link>https://devapt.com/urlsearchparams-query-strings-javascript</link>
            <guid isPermaLink="false">https://devapt.com/urlsearchparams-query-strings-javascript</guid>
            <pubDate>Mon, 27 Dec 2021 09:45:01 GMT</pubDate>
            <description><![CDATA[Learn to use URL and URLSearchParams in Javascript and understand the difference between these two APIs. URLSearchParams is a special case of URL API.]]></description>
            <content:encoded><![CDATA[<p>Reading and manipulating URLs or query strings is involved in various applications for obtaining data from requests and routing users or requests. Different languages have different ways to deal with query parameters or routing at the backend.&nbsp;</p>
<p>In this article, we're going to look at the ways to read and manipulate query strings and URLs using <code>URL</code> and <code>URLSearchParams</code> APIs of Javascript at the client or more specifically in the browser.</p>
<p>In the browser, there's a global variable called <code>location</code> or <code>window.location</code> using which we can get various details about the URL of your active browser tab. Using location property we can get details like full URL, protocol, host, hostname, port, pathname, search params as a string, etc</p>
<p>But to parse and read any URL other than our active tab address, we have <code>URL</code> and <code>URLSearchParams</code> APIs at our disposal in JavaScript.&nbsp;</p>
<p>Let's get into more details of these JavaScript APIs.</p>
<h2 id="how-to-use-url-api-in-js" style="text-align: center;">How to use URL API in JS?</h2>
<p>A <code>URL</code> constructor is used to construct, normalize, parse and encode URLs. It provides various properties to read and manipulate the components of a URL.</p>
<p><code>URL</code> takes an absolute URL string as an argument and returns an object with various properties to read and manipulate the passed URL.&nbsp;</p>
<p>Let's understand this <code>URL</code> by using a sample URL with query params.</p>
<pre class="language-javascript"><code>const parsedUrl = new URL('https://example.com/?name=John Smith&amp;age=25&amp;id=101');
console.log(parsedUrl); // https://example.com/?name=John%20Smith&amp;age=25&amp;id=101</code></pre>
<p>In the above code, we can see that <code>URL</code> could parse the supplied URL string correctly. The <code>parsedUrl</code>&nbsp;can be used as a string directly anywhere we want or we can use the various properties and methods attached to it by the <code>URL</code> class.</p>
<p><code>URL</code> has got most of the properties similar to the <code>window.location</code> object which includes <code>host</code>, <code>hostname</code>, <code>href</code>, <code>origin</code>, <code>port</code>, <code>protocol</code>, <code>search</code>, <code>searchParams</code>, <code>username</code>, <code>password</code> etc.&nbsp;</p>
<pre class="language-javascript"><code>const url = new URL('https://example.com:8080/blog/?name=John Smith&amp;age=25&amp;id=101#heading');

url.host // example.com:8080
url.hostname // example.com
url.href // https://example.com:8080/blog/?name=John%20Smith&amp;age=25&amp;id=101#heading
url.origin // https://example.com:8080
url.pathname // /blog/
url.port // 8080
url.protocol // https:
url.hash // #heading
url.search // ?name=John%20Smith&amp;age=25&amp;id=101
url.searchParams // URLSearchParams {}</code></pre>
<p>So by using <code>URL</code> API we can get various types of info about the URL link that we pass.</p>
<p>If you observe the prop <code>url.searchparams</code> is actually returning the <code>URLSearchParams</code> which we are going to see in the next section.</p>
<p>In certain URLs, we have username and password in the URL itself, and such URLs can be parsed easily to get username and password details using this <code>URL</code> API.</p>
<pre class="language-javascript"><code>const newUrl = new URL('https://john:somePass@dev.example.com/api/test');
console.log(newUrl.username); // john
console.log(newUrl.password); // somePass</code></pre>
<p>To modify any of the props we can just simply assign any valid value to it.&nbsp;</p>
<pre class="language-javascript"><code>const url = new URL('https://example.com:8080/blog/?name=John Smith&amp;age=25&amp;id=101#heading');

url.href = 'https://abc.com';
url.pathname = 'about';
url.hash = '#important';
url.search = '?name=Bond&amp;age=20';
console.log(url); // https://abc.com/about?name=Bond&amp;age=20#important

url.origin = 'https://aaa.com:7777';  // Error: Cannot set property origin</code></pre>
<p>You can set or modify any of the properties of <code>url</code> except <code>origin</code> and <code>searchParams</code> if you try, an error will be thrown.&nbsp;</p>
<h2 id="how-to-use-urlsearchparams-in-js" style="text-align: center;">How to use URLSearchParams in JS?</h2>
<p>In the last section we have seen the ways to read and modify URLs but reading and setting individual URL query strings can be done easily using the <code>URLSearchParams</code> constructor.&nbsp;</p>
<p><code>URLSearchParams</code> takes the query string of a URL as argument and returns an iterable object with various methods to read and manipulate the query parameters. If you pass a full URL to the <code>URLSearchParams</code> it will clip off the inital param after <code>?</code>. So it's always good to pass only the query string part of the URL or just pass query string as an object with key value pairs.</p>
<pre class="language-javascript"><code>const link = 'https://example.com/blog?name=john&amp;age=25&amp;id=101&amp;name=smith';
const url = new URL(link);
const searchParams = new URLSearchParams(url.search); // For active browser link, use location.search

searchParams.get('name'); // john
searchParams.getAll('name'); // ["john", "smith"]
searchParams.has('age'); // true
searchParams.toString(); // name=john&amp;age=25&amp;id=101&amp;name=smith
searchParams.append('place', 'Munich'); // Adding a new query param
searchParams.set('id', '222'); // Updating the id to 222
searchParams.toString(); // name=john&amp;age=25&amp;id=222&amp;name=smith&amp;place=Munich
searchParams.delete('place'); 
searchParams.toString(); // name=john&amp;age=25&amp;id=222&amp;name=smith</code></pre>
<p>There are other methods like <code>keys</code>, <code>values</code>, <code>entries</code> and <code>forEach</code>(iterates over the values) to iterate the search params.&nbsp;</p>
<p>Other than <code>forEach</code> method all return iterables so array methods like forEach can't be run on those. We need to convert them to an array and use methods like forEach, map etc.&nbsp;</p>
<pre class="language-javascript"><code>const searchParams = new URLSearchParams('name=john&amp;age=25&amp;id=101');

searchParams.forEach(v =&gt; console.log(v)); // john 25 101
Array.from(searchParams.keys()).forEach(k =&gt; console.log(k)); // name age id
Array.from(searchParams.values()).forEach(v =&gt; console.log(v)); // john 25 101
Object.fromEntries(searchParams.entries()); // {name: "john", age: "25", id: "101"}</code></pre>
<p>In the above code snippet for the methods <code>keys</code>, <code>values</code> and <code>entries</code> we converted them to arrays and object to see the results.</p>
<p>Now if we go back to the <code>URL</code> API methods, we have <code>searchParams</code> method there, using that we can get all the details that we could get using <code>URLSearchParams</code> except that we cannot set any query parameters from there.&nbsp;</p>
<pre class="language-javascript"><code>const url = new URL('https://example.com/?name=John Smith&amp;age=25&amp;id=101');
url.searchParams.get('name') // John Smith
url.searchParams.has('age') // true
url.searchParams.toString() //name=John+Smith&amp;age=25&amp;id=101
url.searchParams.forEach(i=&gt; console.log(i)) //John Smith 25 101
Object.fromEntries(url.searchParams.entries()) // {name: "John Smith", age: "25", id: "101"}</code></pre>
<blockquote>
<p>Using <code>URL</code> we can pass full URL address and can still read the correct query params unlike <code>URLSearchParams</code> where we need to pass only the query string to read the correct query parameters data.</p>
</blockquote>
<p>So that's all about <code>URL</code> and <code>URLSearchParams</code> in Javascript. In conclusion what we can infer is in most of the cases to read the query strings we you just need to use <code>URL</code> API.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Everything about path.join vs path.resolve in NodeJS ]]></title>
            <link>https://devapt.com/path-join-vs-resolve-node</link>
            <guid isPermaLink="false">https://devapt.com/path-join-vs-resolve-node</guid>
            <pubDate>Fri, 24 Dec 2021 16:45:45 GMT</pubDate>
            <description><![CDATA[Here is the clear insight about the path join vs resolve in NodeJS. Understand when to use what based on different scenarios.]]></description>
            <content:encoded><![CDATA[<p><code>path</code> is the inbuilt module in <a href="https://nodejs.org/docs/latest-v14.x/api/path.html" target="_blank" rel="noopener">NodeJs</a>. It is often used to generate absolute paths for files or resources. <code>join</code> and <code>resolve</code> are the quite commonly and interchangeably used methods of the <code>path</code> module.&nbsp;</p>
<p>In most of the cases the way join and resolve methods used by us lead to the same result but there's a notable difference between those methods, understanding which can help us to use the <code>path</code> module effectively.&nbsp;</p>
<pre class="language-javascript"><code>path.join(__dirname, 'public/logo.png'); // /home/user/project_dir/public/log.png
path.resolve(__dirname, 'public/logo.png'); // /home/user/project_dir/public/log.png</code></pre>
<p>In the above code snippet <code>__dirnname</code> is a global variable that gives the absolute path of your project directory.</p>
<pre class="language-javascript"><code>console.log(__dirname); // /home/user/project_dir</code></pre>
<p>To quickly get an idea of the difference between <code>path.join</code> and <code>path.resolve</code>, just remove the <code>__dirname</code> from both the methods in the above codes and observe the results.</p>
<pre class="language-javascript"><code>path.join('public/logo.png'); // public/log.png
path.resolve('public/logo.png'); // /home/user/project_dir/public/log.png</code></pre>
<p>So it should have given some idea of how <code>join</code> and <code>resolve</code> methods are working. Let's dive into more details and differences between these two methods.</p>
<h2 id="difference-between-path-join-vs-resolve">Difference between path join vs resolve</h2>
<h3 id="understanding-pathjoin-method">Understanding <code>path.join</code> method</h3>
<p><code>join</code> method takes path segments as arguments and joins them together using the platform-specific separator(<code>/</code> in Linux and <code>\</code> in Windows) as a delimiter and then normalizes the resulting path.</p>
<p>So <code>path.join</code> simply joins the paths that are given to it. Let's have different scenarios below.</p>
<pre class="language-javascript"><code>path.join('a', 'b', 'c'); // a/b/c
path.join('a', '/b', 'c'); // a/b/c
path.join('a', 'b', '../c'); // a/c -&gt; normalized
path.join(''); // .
path.join(); // -&gt; No result because zero length path segments are ignored
path.join(__dirname, 'public/logo.png'); // /home/user/project_dir/public/log.png</code></pre>
<p>The path segment for <code>__dirname</code> as seen earlier is <code>/home/user/project_dir</code> so joining that with <code>public/logo.png</code> gives&nbsp;</p>
<pre class="language-markup"><code>/home/user/project_dir/public/log.png</code></pre>
<p>Make a note that <code>path.join</code> takes only valid strings as path segments else it will throw an error.</p>
<p>Now let's understand path.resolve.</p>
<h3 id="understanding-pathresolve-method">Understanding <code>path.resolve</code> method</h3>
<p><code>resolve</code> method takes path segments as arguments just like the <code>join</code> method but it resolves or returns an absolute path always with normalization(which means ../.. such paths get resolved) and that's the main difference between <code>join</code> and <code>resolve</code>.</p>
<p>But few things need to be taken care of to get the correct absolute path from the <code>path.resolve</code>. For instance, the given sequence of paths or path segments are processed from right to left, with each subsequent <code>path</code> prepended until an absolute path is constructed.&nbsp;</p>
<p>Let's see various <code>path.resolve</code> scenarios to understand it better.</p>
<pre class="language-javascript"><code>path.resolve('a', 'b', 'c'); // /home/user/project_dir/a/b/c
path.resolve('a', '/b', 'c'); // /b/c -&gt; from right to left until it encounters '/' is considered for absolute path
path.resolve('a', 'b', '../c'); // /home/user/project_dir/a/c -&gt; normalized
path.resolve(''); // /home/user/project_dir/
path.resolve(); // /home/user/project_dir/
</code></pre>
<p>Just like <code>path.join</code>, <code>resolve</code> also takes only the valid path segments as arguments else it will throw an error.</p>
<p>So it should be clear by now that <code>join</code> just joins the path segments given as arguments where as <code>resolve</code> joins or resolves the path segments with the absolute path of the root directory or the absolute path that is given as an argument to the <code>path.resolve</code>.&nbsp;</p>
<p>From this understanding of these methods, we can avoid <code>path.join</code> most of the times to obtain an absolute path using <code>__dirname</code>, because <code>path.resolve</code> actually takes into account the absolute path of the root directory while resolving the path segments.</p>
<pre class="language-javascript"><code>__dirname === path.resolve() // true</code></pre>
<pre class="language-javascript"><code>// Instead of this
path.join(__dirname, 'public/logo.png'); // /home/user/project_dir/public/log.png

// You can use this to get the absolute path
path.resolve('public/logo.png'); // /home/user/project_dir/public/log.png</code></pre>
<blockquote>
<p>Keep in mind that whenever <code>path.resolve</code> encounters <code>/</code> for the first time from right to left it ends the path until there as the absolute path.&nbsp;</p>
</blockquote>
<p>And that is all about path join vs resolve details. Hope this article has clarified and given you a clear understanding of the differences between these two methods.&nbsp;</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
        <item>
            <title><![CDATA[Demystifying call, apply, bind in JavaScript]]></title>
            <link>https://devapt.com/call-apply-bind-javascript</link>
            <guid isPermaLink="false">https://devapt.com/call-apply-bind-javascript</guid>
            <pubDate>Thu, 23 Dec 2021 08:00:37 GMT</pubDate>
            <description><![CDATA[Call, apply, bind in JavaScript are some of the most often confusing methods. Let's demystify these with simple examples.]]></description>
            <content:encoded><![CDATA[<p>The keyword <code>this</code> in JavaScript is one of the most muddling concepts because its value depends on where it is used. Often it tricks developers and sometimes it's the culprit behind surreal results.</p>
<p>Let's discuss this <code>this</code> keyword with simple and easy to understand examples before actually delving into the <code>call</code>, <code>apply</code>, and <code>bind</code> methods as <code>this</code> keyword is the main reason for having those methods.</p>
<h2 id="what-is-this-in-javascript">What is <code>this</code> in JavaScript?</h2>
<p>The <code>this</code> keyword in JavaScript refers to the object that the function is a property of and <code>this</code> will depend on the object that is invoking the function.&nbsp;</p>
<p>To get a quick idea of <code>this</code> have a look at the code snippet below.</p>
<pre class="language-javascript"><code>const myObj = {
  name: 'John',
  age: 25,
  place: 'London',
  myFunction: function() {
    return this;
  }
};

myObj.myFunction(); 
// {name: "John", age: 25, place: "London", myFunction: &fnof;()}</code></pre>
<p>In the above code snippet, you can see that when <code>myFunction</code> method is called it returns the value of <code>this</code>, which is nothing but the <code>myObj</code> itself. If you recollect the definition for <code>this</code> in the previous paragraph, it says <code>this</code> refers to the object that the function is a property of, so here <code>myFunction</code> is a property of <code>myObj</code>, which means <code>this</code> is referring to that <code>myObj</code> object.&nbsp;</p>
<p>A <em>simple trick</em> is <span style="background-color: #fbeeb8;">whatever precedes before .(dot) is the object referenced by the <code>this</code></span> keyword. So before .(dot) in <code>myObj.myFunction()</code> is <code>myObj</code>, which is the value of <code>this</code>.</p>
<p>Let's take another example to understand this.</p>
<pre class="language-javascript"><code>function myFunction() {
  return this;
}

myFunction(); // window or undefined(in case of 'strict mode')</code></pre>
<p>In the above code we are returning <code>this</code> from the <code>myFunction</code>, so when <code>myFunction</code> is called what we see or get is the value of <code>this</code>.</p>
<p>Again if we recollect our definition of <code>this</code>, it refers to the object which the function is a property of. Here our function <code>myFunction</code> is a property of global object nothing but the <code>window</code> object in the browser, so which means when we call <code>myFunction</code> the value of <code>this</code> is going to be the <code>window</code> object.&nbsp;</p>
<p>If we go by our trick of .(dot) preceding the function, here there's no dot but every function is a method in the <code>window</code> object, so it translates to <code>window.myFunction()</code> so here, the <code>this</code> keyword refers to the <code>window</code> object.&nbsp;</p>
<p>In order to avoid functions getting attached to the window object, we <code>use strict</code> mode so as a result window will be <code>undefined</code> in such cases.&nbsp;</p>
<p>So keep in mind our definition as we're going to use that for understanding <code>call</code>, <code>apply</code> and <code>bind</code> methods.&nbsp;</p>
<blockquote>
<p>The <strong>this keyword</strong> in JavaScript <strong>refers to the object that the function is a property of</strong> and this will depend on the object that is invoking the function.&nbsp;</p>
</blockquote>
<h2 id="understanding-call-apply-bind-in-javascript">Understanding call, apply, bind in JavaScript</h2>
<p>Let's consider an object <code>person</code> with a property <code>name</code> and a method <code>details</code>.</p>
<pre class="language-javascript"><code>const person = {
  name: 'John',
  details: function(age, place) {
    return `${this.name} ${age} years old, lives in ${place}`
  }
}

person.details(25, 'London'); //John 25 years old, lives in London</code></pre>
<p>When we call the method <code>details</code> on <code>person</code> object with the arguments, we knew that <code>this</code> refers to the <code>person</code> object because <code>details</code> is a property of the <code>person</code> object and so <code>this.name</code> would be <em>John</em> and so the result that gets returned will be as shown in the comments.</p>
<p>This part is going to be clear as we knew what <code>this</code> means in the <code>person</code> object.</p>
<p>Let's consider a scenario where we wanted to use the <code>details</code> method but with different arguments.</p>
<p>As per the <code>details</code> method we can pass in different age and place values but how about the name, as it is connected with the <code>this</code> keyword? This is where we are going to use those special methods <code>call</code>, <code>apply</code> and <code>bind</code>. Let's dive into those.</p>
<h3 id="using-call-method">Using <code>call</code> method</h3>
<p>Now we want to associate a different object other than <code>person</code> to <code>this</code> keyword of <code>details</code> method. So to do that we're going to use the <code>call</code> method as shown below in the code snippet.</p>
<pre class="language-javascript"><code>person.details.call({ name: 'James'}, 30, 'Tokyo'); 
// James 30 years old, lives in Tokyo</code></pre>
<p>A <code>call</code> method takes a new object that we want this to refer to followed by the arguments to the function(nothing but the <code>details</code> method) and it gets called referencing <code>this</code> to the new object passed as the first argument. Voila! That's what a call method is.&nbsp;</p>
<h3 id="using-apply-method">Using <code>apply</code> method</h3>
<p>Guess what, <code>apply</code> method is just the same as the <code>call</code> method, that is, it takes a new object as the first argument to reference the <code>this</code> keyword and is followed by an array of arguments. So it means you can simply pass the arguments to the <code>details</code> function in the form of an array instead of passing individually. Have a look at the code below so it becomes clear for you.</p>
<pre class="language-javascript"><code>person.details.apply({ name: 'James'}, [30, 'Tokyo']); 
// James 30 years old, lives in Tokyo</code></pre>
<p>So <code>call</code> and <code>apply</code> methods are used to reference a new object to <code>this</code> keyword on methods.</p>
<p>And then what <code>bind</code> is for? Guess!</p>
<h3 id="using-bind-method">Using <code>bind</code> method</h3>
<p>When <code>call</code> and <code>apply</code> methods are applied they are called(invoked) directly referencing the new object passed but in order to get a new function reference that can be used to call at later times, the <code>bind</code> method is used. Have a look at the code snippet below to get more clarity.</p>
<pre class="language-javascript"><code>const personDetails = person.details.bind({name: 'William'}, 40, 'Rome');

personDetails(); 
// William 40 years old, lives in Rome</code></pre>
<p>So using the <code>bind</code> method returns a new function reference which can be called at a later time and that is all about the bind method.</p>
<p>So putting all the three methods together.</p>
<pre class="language-javascript"><code>const person = {
  name: 'John',
  details: function(age, place) {
    return `${this.name} ${age} years old, lives in ${place}`
  }
}

person.details(25, 'London');  //John 25 years old, lives in London

// Using call
person.details.call({ name: 'James'}, 30, 'Tokyo'); // James 30 years old, lives in Tokyo

// Using apply
person.details.apply({ name: 'James'}, [30, 'Tokyo']); // James 30 years old, lives in Tokyo

// Using bind
const personDetails = person.details.bind({name: 'William'}, 40, 'Rome');
personDetails();  // William 40 years old, lives in Rome</code></pre>
<p>So in short CAB(call, apply, bind in JavaScript) are used to reference a new owner object to the <code>this</code> keyword. Hope this article has demystified the call, apply and bind methods in JS.</p>
<p>Did we miss anything here? Yes, the <code>this</code> value will be different when we use an arrow function. See you in the next article.</p>]]></content:encoded>
            <author>godevapt@gmail.com (WahVinci)</author>
        </item>
    </channel>
</rss>