<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sarvesh Dubey</title>
    <description>The latest articles on Forem by Sarvesh Dubey (@dubesar).</description>
    <link>https://forem.com/dubesar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F493174%2F12537708-6c15-4e5a-9e76-07e63b37e50c.jpeg</url>
      <title>Forem: Sarvesh Dubey</title>
      <link>https://forem.com/dubesar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dubesar"/>
    <language>en</language>
    <item>
      <title>How we manage Backend Services at Fusion</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Sun, 21 Nov 2021 17:54:13 +0000</pubDate>
      <link>https://forem.com/dubesar/how-we-manage-backend-services-at-fusion-5ejl</link>
      <guid>https://forem.com/dubesar/how-we-manage-backend-services-at-fusion-5ejl</guid>
      <description>&lt;p&gt;It’s been around 1.5months we shifted the entire backend services to AWS, being previously on Heroku. Coming from Heroku background it’s quite different to have your services running on AWS!!&lt;/p&gt;

&lt;p&gt;We have 5 different services running on a single Kubernetes cluster with three nodes of t2.medium and all in autoscale mode!!&lt;/p&gt;

&lt;p&gt;Also a big thanks to porter.run for making it as simple as Heroku to deploy stuffs!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What all services are currently running at Fusion?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Event-collector service (tracking engine) — Javascript&lt;/li&gt;
&lt;li&gt;Query Service (query engine) — Javascript&lt;/li&gt;
&lt;li&gt;Email service — Python&lt;/li&gt;
&lt;li&gt;User service — Python&lt;/li&gt;
&lt;li&gt;Payments service — Python&lt;/li&gt;
&lt;li&gt;Chat Service (Currently running on Heroku)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What type of services are these and how much intensive?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Event-collector (this is the most intensive service bearing a lot of requests being made in a single interval of time)
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NcmtvByV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tjan0ipf0k9ldbolfhqu.png" alt="Current Event Collector" width="880" height="495"&gt;
&lt;/li&gt;
&lt;li&gt;Query Service (DB LookUp service)&lt;/li&gt;
&lt;li&gt;Email Service (A SMTP server for email campaigns)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;How we do use event collector?&lt;/strong&gt;&lt;br&gt;
It’s purely asynchronous, also will be adding queuing service of Redis/RabbitMQ. As we can register events in a lazy manner!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do we use Query Service?&lt;/strong&gt;&lt;br&gt;
This is something where we are entirely dependent on the DB service/RDS which we use for PostgreSQL. We will be soon shifting to ClickHouse(Column based DB)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do we use Email Service?&lt;/strong&gt;&lt;br&gt;
Currently we are only using queuing to scale the email service and this can be used to pretty large number of emails to be sent in a batch!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RDS Used?&lt;/strong&gt;&lt;br&gt;
Currently we are entirely using AWS RDS for PostgreSQL. But will be soon moving to ClickHouse DB!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How far we are at Fusion?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;#1 product of the week on Remote.Tools&lt;/li&gt;
&lt;li&gt;#1 product of the day on BetaList&lt;/li&gt;
&lt;li&gt;Featured on Product Hunt&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What are we trying to do?&lt;/strong&gt;&lt;br&gt;
We are bringing an open source alternative for Amplitude/Mixpanel, Hotjar/Smartlook, Mailchimp, CleverTap/WebEngage&lt;/p&gt;

&lt;p&gt;Also we are open-source, soon to be releasing the newest patch of codes!! Stay Tuned in for more engineering blogs!&lt;/p&gt;

</description>
      <category>analytics</category>
      <category>javascript</category>
      <category>python</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Video Analytics - Future of Analytics?</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Mon, 15 Nov 2021 08:13:15 +0000</pubDate>
      <link>https://forem.com/dubesar/video-analytics-future-of-analytics-210l</link>
      <guid>https://forem.com/dubesar/video-analytics-future-of-analytics-210l</guid>
      <description>&lt;p&gt;Hello from Sarvesh - one of the co-founders at &lt;a href="https://fusionhq.co"&gt;https://fusionhq.co&lt;/a&gt;, excited to share some deep insights into the world of video analytics! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Video Analytics?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Video Analytics can be understood something related to monitoring the user's behaviour for your product! Often it happens you have event analytics turned on giving you the product usage in an abstracted manner but doesn't provides the exact sense of product usage leading to less behavioural insights of product usage. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Let's take a scenario?&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;You have a product XYZ and you are tracking a certain KPI of login dropoff on the platform! And you have certain A tool tracking events for that purpose. Now let's assume two scenarios.&lt;/p&gt;

&lt;p&gt;a. A person clicks on the Login button&lt;br&gt;
b. A person doesn't clicks on the Login button&lt;/p&gt;

&lt;p&gt;But you get to know that you have a high dropoff on that step. Now you are bound to see what was the behaviour of users dropping off at the location/instance!! But you can't simply do it with a regular event analytics tool!&lt;/p&gt;

&lt;p&gt;Let's assume now you want to run an A/B testing for that section. But you don't have any POC of what you should do to incur a lower dropoff than before! You can do it in random but not in targetted manner leading to more time wastage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does Fusion helps in Video Analytics?&lt;/strong&gt;&lt;br&gt;
At Fusion we care for both company's time and also development effort and minimize the efforts with larger output and assured success!&lt;/p&gt;

&lt;p&gt;We provide with the visual analysis of your product through small video recordings and help to see the visual journey of a particular user and then convert him by either engaging him or running an A/B testing for a certain set of users. (A/B testing in pipeline yet to be developed). &lt;/p&gt;

&lt;p&gt;You can view product usage videos and take actions according to that with backing of event analytics to confirm you POC and run engagement in a certain targetted manner!&lt;/p&gt;

&lt;p&gt;Hope you like the article and definitely visit &lt;a href="https://fusionhq.co"&gt;https://fusionhq.co&lt;/a&gt; for more insights. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building FusionHQ - All-in-one user analytics &amp; engagement platform.</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Fri, 01 Oct 2021 19:06:42 +0000</pubDate>
      <link>https://forem.com/dubesar/building-fusionhq-all-in-one-user-analytics-engagement-platform-2op4</link>
      <guid>https://forem.com/dubesar/building-fusionhq-all-in-one-user-analytics-engagement-platform-2op4</guid>
      <description>&lt;p&gt;Hello All, I am Sarvesh, one of the co-founders of Fusion. We have been building Fusion for the last 5 months and really excited to share about it!!&lt;/p&gt;

&lt;p&gt;Let's answer some questions to get the vision and idea of the product clear.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Fusion?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fusion is an all-in-one user behaviour analytics and engagement suite.&lt;/p&gt;

&lt;p&gt;It's built upon a lightweight no-code mixpanel-like analytics engine but we are not another analytics platform, Fusion uses it to gather users' personal &amp;amp; product usage data and share it with built-in live-chat, push-notification, and email/micro survey tools.&lt;/p&gt;

&lt;p&gt;Fusion shows how your users interact with your web-based products eg: page-views, button clicks, form submissions, etc. But apart from this, Fusion lets you run targeted engagements with a specific user or group of users in real-time over live-chat, push in-app notification &amp;amp; email/micro-surveys or you can set up to trigger these engagements automatically.&lt;/p&gt;

&lt;p&gt;These targeted users could be people who have something in common(eg: users from a specific country/marketing referral) or users who performed a particular action on the website (eg: visited pricing page but did not sign up).&lt;/p&gt;

&lt;p&gt;Fusion helps small teams in these ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;No need to continuously monitor multiple SAAS tools and jump tabs, manage everything from one lightweight dashboard or directly from slack (or teams etc) instead of going back and forth between multiple windows.&lt;/li&gt;
&lt;li&gt;No-code auto-capture requires zero engineering efforts for tracking. Just copy-paste one snippet on your website and that works for analytics, chat, CRM &amp;amp; email instead of coding up 5 different trackers on your product.&lt;/li&gt;
&lt;li&gt;Run real-time targeted engagements with single-user/specific type of users or users who performed a particular action, ensuring less spam and more conversion. And again analyse how users reacted to those campaigns.&lt;/li&gt;
&lt;li&gt;Reduced SAAS bills as Fusion is one platform so you pay one base subscription instead of multiple.&lt;/li&gt;
&lt;li&gt;Teams can avoid crappy built-in plugins for connecting multiple SAAS tools or using expensive CDPs like Segment.com . Seamless user data flows between analytics, CRM, marketing stack as they are in one platform.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Where can you find Fusion?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fusion is available &lt;a href="https://fusionhq.co"&gt;here&lt;/a&gt; or the github is available &lt;a href="https://github.com/fusion-hq"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where are we on building Fusion?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have completed the Analytics Engine and currently chat service is being developed and other lots of features coming soon!!&lt;/p&gt;

&lt;p&gt;Interested in using the product? Connect &lt;a href="https://fusionhq.co"&gt;here&lt;/a&gt;. Show us your love &lt;a href="https://www.producthunt.com/posts/fusion-4"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So let's connect to give some more info on the product!!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>analytics</category>
      <category>python</category>
      <category>opensource</category>
    </item>
    <item>
      <title>VueJS + Tailwind Basic Modal in 5 mins</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Thu, 07 Jan 2021 03:27:00 +0000</pubDate>
      <link>https://forem.com/dubesar/vuejs-tailwind-basic-modal-in-5-mins-1njl</link>
      <guid>https://forem.com/dubesar/vuejs-tailwind-basic-modal-in-5-mins-1njl</guid>
      <description>&lt;p&gt;Modals can be used for various purposes right from showing instructions with a pop-up or getting some form inputs. I will be building a modal that you can use for any sort of purpose and using any type of modal from instructions to form input collection.&lt;/p&gt;

&lt;p&gt;We will use VueJS and TailwindCSS for this purpose. Also if you suck at creating styles just go and grab a modal style from &lt;a href="https://tailwindcomponents.com/components/modals"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I have grabbed &lt;a href="https://tailwindcomponents.com/component/awesome-modal"&gt;this&lt;/a&gt; as I want to make a pop-up instruction as soon as the DOM is ready. Let's grab the code!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;dialog&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;open&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;appear&lt;/span&gt; &lt;span class="m"&gt;.15s&lt;/span&gt; &lt;span class="n"&gt;cubic-bezier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1.8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1.8&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;dialog&lt;/span&gt;&lt;span class="nd"&gt;::backdrop&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;linear-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;45deg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="py"&gt;backdrop-filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;3px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;appear&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;from&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-3rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;to&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;dialog&lt;/span&gt; &lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"myModal"&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"h-auto w-11/12 md:w-1/2 p-5  bg-white rounded-md "&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"flex flex-col w-full h-auto "&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;Header&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"flex w-full h-auto justify-center items-center"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"flex w-10/12 h-auto py-3 justify-center items-center text-2xl font-bold"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;Modal&lt;/span&gt; &lt;span class="nt"&gt;Header&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;onclick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"document.getElementById('myModal').close();"&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"flex w-1/12 h-auto justify-center cursor-pointer"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;svg&lt;/span&gt; &lt;span class="nt"&gt;xmlns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"http://www.w3.org/2000/svg"&lt;/span&gt; &lt;span class="nt"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"24"&lt;/span&gt; &lt;span class="nt"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"24"&lt;/span&gt; &lt;span class="nt"&gt;viewBox&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"0 0 24 24"&lt;/span&gt; &lt;span class="nt"&gt;fill&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"none"&lt;/span&gt; &lt;span class="nt"&gt;stroke&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"#000000"&lt;/span&gt; &lt;span class="nt"&gt;stroke-width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"2"&lt;/span&gt; &lt;span class="nt"&gt;stroke-linecap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"round"&lt;/span&gt; &lt;span class="nt"&gt;stroke-linejoin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"round"&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"feather feather-x"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;line&lt;/span&gt; &lt;span class="nt"&gt;x1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"18"&lt;/span&gt; &lt;span class="nt"&gt;y1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"6"&lt;/span&gt; &lt;span class="nt"&gt;x2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"6"&lt;/span&gt; &lt;span class="nt"&gt;y2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"18"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;line&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;line&lt;/span&gt; &lt;span class="nt"&gt;x1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"6"&lt;/span&gt; &lt;span class="nt"&gt;y1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"6"&lt;/span&gt; &lt;span class="nt"&gt;x2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"18"&lt;/span&gt; &lt;span class="nt"&gt;y2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"18"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;line&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;svg&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="nt"&gt;--Header&lt;/span&gt; &lt;span class="nt"&gt;End--&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;Modal&lt;/span&gt; &lt;span class="nt"&gt;Content--&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
           &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"flex w-full h-auto py-10 px-2 justify-center items-center bg-gray-200 rounded text-center text-gray-500"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
             &lt;span class="nt"&gt;This&lt;/span&gt; &lt;span class="nt"&gt;is&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="nt"&gt;text&lt;/span&gt; &lt;span class="nt"&gt;inside&lt;/span&gt; &lt;span class="nt"&gt;the&lt;/span&gt; &lt;span class="nt"&gt;modal&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;You&lt;/span&gt; &lt;span class="nt"&gt;can&lt;/span&gt; &lt;span class="nt"&gt;add&lt;/span&gt; &lt;span class="nt"&gt;your&lt;/span&gt; &lt;span class="nt"&gt;content&lt;/span&gt; &lt;span class="nt"&gt;here&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;!&lt;/span&gt;&lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;End&lt;/span&gt; &lt;span class="nt"&gt;of&lt;/span&gt; &lt;span class="nt"&gt;Modal&lt;/span&gt; &lt;span class="nt"&gt;Content--&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;dialog&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will not use the button as we don't have to use the button to get the modal content on to the DOM. We will use the VueJS Lifecycle method to do so!&lt;/p&gt;

&lt;p&gt;First, let's go through the above code, we are using animation open once it's open we have to set the background and we use backdrop and background to see the blur and background color.&lt;/p&gt;

&lt;p&gt;We also use keyframes to show a certain transition in the X direction as when the modal appears on the DOM it has a certain transition of 3rem on the screen.&lt;/p&gt;

&lt;p&gt;Now we will use VueJS to show the modal as soon as all the elements have been rendered on the DOM.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;el&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;mounted&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;openModal&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;methods&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;openModal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;myModal&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;showModal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find the above code on my &lt;a href="https://github.com/dubesar/VueJS-Modal/blob/main/src.js"&gt;github&lt;/a&gt;. The code is basically using the mounted lifecycle method. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is mounted?&lt;/strong&gt; : Basically executes the code once the elements are rendered on the DOM&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Other Lifecycle methods&lt;/strong&gt; : &lt;code&gt;updated, mounted, destroyed, activated&lt;/code&gt;. You can see all the API's &lt;a href="https://vuejs.org/v2/api/#Options-Lifecycle-Hooks"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Do share the article if you find it useful! 😍
&lt;/h3&gt;

</description>
      <category>css</category>
      <category>javascript</category>
      <category>vue</category>
    </item>
    <item>
      <title>Interview JS Part 5 - Map, Reduce, Filter</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Fri, 01 Jan 2021 07:59:02 +0000</pubDate>
      <link>https://forem.com/dubesar/interview-js-part-5-map-reduce-filter-hac</link>
      <guid>https://forem.com/dubesar/interview-js-part-5-map-reduce-filter-hac</guid>
      <description>&lt;p&gt;Sorry, this article came to the blog a lot later than expected. We shall cover a small topic in this part regarding most use functions or let's most used and useful thing while writing JS and particularly React.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a Map?
&lt;/h3&gt;

&lt;p&gt;Map according to the definition should be mapping some value to something. Similarly here too we have a function mapping to each individual element in the array. Map in JavaScript binds to each value and the value can be considered as the returned value of that function and thus the Map returns the array of function bind values.&lt;/p&gt;

&lt;p&gt;If the above seems something not very obvious to you let's go through an example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;thisArg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's do it by halving each element of the array in JavaScript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;halves&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// halves = [2, 4, 6, 7]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What is Filter?
&lt;/h3&gt;

&lt;p&gt;Filter in real life means to remove something that does not follow a particular function. Similarly, in JS we have a filter that is used to remove the none required elements in the array. &lt;/p&gt;

&lt;p&gt;Filter returns an array of filtered elements according to the given callback function. Similar to Map it's basically putting each element on test for a condition.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;thisArg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's write a code that removes the element below 5:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nums&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newNum&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;newNum&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// nums is [10,15]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What is Reduce?
&lt;/h3&gt;

&lt;p&gt;This is something special! Generally, people use it to just find the sum of the array but this provides much more than this.&lt;/p&gt;

&lt;p&gt;By meaning, Reduce is used to reduce something to something else. &lt;br&gt;
The most famous example is obvious to find the sum of the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prevVal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;initialValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// 10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So now what else can be done apart from this, apart from multiplying too!!&lt;/p&gt;

&lt;p&gt;We have something called compose which uses reduce:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;compose&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;fns&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;fns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduceRight&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addThenmult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;compose&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;mult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;add&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;addThenmult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 6&lt;/span&gt;
&lt;span class="c1"&gt;// ((2 + x = z) * y)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Chaining Promises ( Got to know from &lt;a href="https://medium.com/@bojangbusiness/javascript-functional-programming-map-filter-and-reduce-846ff9ba492d"&gt;Source&lt;/a&gt;)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;itemIDs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; 
&lt;span class="nx"&gt;itemIDs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;itemID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deleteItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;itemID&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code resolves to:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deleteItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deleteItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deleteItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deleteItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;deleteItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Making promises in a chain is really a unique way to use reduce.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stay Tuned for other articles on InterviewJS.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Interview OS (Part 2A) - Important Terms in OS</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Thu, 24 Dec 2020 07:17:34 +0000</pubDate>
      <link>https://forem.com/dubesar/interview-os-part-2a-important-terms-in-os-5325</link>
      <guid>https://forem.com/dubesar/interview-os-part-2a-important-terms-in-os-5325</guid>
      <description>&lt;p&gt;Disclaimer - Thanks to Love Babbar for this list of important terms that are required to be known in OS.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compiler&lt;/li&gt;
&lt;li&gt;Loader &lt;/li&gt;
&lt;li&gt;Assembler &lt;/li&gt;
&lt;li&gt;Interpreter&lt;/li&gt;
&lt;li&gt;System Calls&lt;/li&gt;
&lt;li&gt;API (Application Programming Interface)&lt;/li&gt;
&lt;li&gt;Kernel &lt;/li&gt;
&lt;li&gt;Shell&lt;/li&gt;
&lt;li&gt;JVM &lt;/li&gt;
&lt;li&gt;Booting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article, we will go through the first 4 parts of the list and then will complete the rest in the next article.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compiler&lt;/strong&gt;-&lt;br&gt;
A compiler is a program that translates a source program written in some high-level programming language (such as Java) into machine code for some computer architecture (such as the Intel Pentium architecture). The generated machine code can be later executed many times against different data each time. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://lambda.uta.edu/cse5317/notes/node3.html"&gt;Source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Interpreter&lt;/strong&gt; - &lt;br&gt;
An interpreter reads an executable source program written in a high-level programming language as well as data for this program, and it runs the program against the data to produce some results. One example is the Unix shell interpreter, which runs operating system commands interactively.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://lambda.uta.edu/cse5317/notes/node3.html"&gt;Source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To clear some doubts the below context is taken from:- &lt;code&gt;"Compilers, Principles, Techniques, &amp;amp; Tools", Aho, Lam, Sethi, Ullman, (Pearson International Edition, 2007), pages 1, 2&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The two basic mechanisms for processing a program are compilation and interpretation.&lt;/p&gt;

&lt;p&gt;Compilation takes as input a source program in a given language and outputs a target program in a target language.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;source program --&amp;gt; | compiler | --&amp;gt; target program&lt;/code&gt;&lt;br&gt;
If the target language is machine code, it can be executed directly on some processor:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;input --&amp;gt; | target program | --&amp;gt; output&lt;/code&gt;&lt;br&gt;
A compilation involves scanning and translating the entire input program (or module) and does not involve executing it.&lt;/p&gt;

&lt;p&gt;Interpretation takes as input the source program and its input and produces the source program's output&lt;/p&gt;

&lt;p&gt;&lt;code&gt;source program, input --&amp;gt; | interpreter | --&amp;gt; output&lt;/code&gt;&lt;br&gt;
Interpretation usually involves processing (analyzing and executing) the program one statement at a time.&lt;/p&gt;

&lt;p&gt;In practice, many language processors use a mix of the two approaches. E.g., Java programs are first translated (compiled) into an intermediate program (byte code):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;source program --&amp;gt; | translator | --&amp;gt; intermediate program&lt;/code&gt; &lt;br&gt;
the output of this step is then executed (interpreted) by a virtual machine:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;intermediate program + input --&amp;gt; | virtual machine | --&amp;gt; output&lt;/code&gt;&lt;br&gt;
To complicate things even further, the JVM can perform just-in-time compilation at runtime to convert byte code into another format, which is then executed.&lt;/p&gt;

&lt;p&gt;Also, even when you compile to machine language, there is an interpreter running your binary file which is implemented by the underlying processor. Therefore, even in this case, you are using a hybrid of compilation + interpretation.&lt;/p&gt;

&lt;p&gt;So, real systems use a mix of the two so it is difficult to say whether a given language processor is a compiler or an interpreter, because it will probably use both mechanisms at different stages of its processing. In this case, it would probably more appropriate to use another, more neutral term.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GtFRjdzN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1608706593726/jPr7oGEkM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GtFRjdzN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1608706593726/jPr7oGEkM.png" alt="targetlang.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Loader&lt;/strong&gt;- &lt;br&gt;
A loader is a major component of an operating system that ensures all necessary programs and libraries are loaded, which is essential during the startup phase of running a program. It places the libraries and programs into the main memory in order to prepare them for execution. Loading involves reading the contents of the executable file that contains the instructions of the program and then doing other preparatory tasks that are required in order to prepare the executable for running, all of which takes anywhere from a few seconds to minutes depending on the size of the program that needs to run.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.quora.com/What-is-loader-in-system-programing"&gt;Source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not all code and libraries are loaded at program startup, only the ones required for actually running the program. Other libraries are loaded as the program runs, or only as required. This is especially true for applications such as games that only need assets loaded for the current level or location that the player is in.&lt;/p&gt;

&lt;p&gt;Responsibilities of Loader:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Validate the program for memory requirements, permissions, etc.&lt;/li&gt;
&lt;li&gt;Copy necessary files, such as the program image or required libraries, from the disk into the memory&lt;/li&gt;
&lt;li&gt;Copy required command-line arguments into the stack&lt;/li&gt;
&lt;li&gt;Link the starting point of the program and link any other required library&lt;/li&gt;
&lt;li&gt;Initialize the registers&lt;/li&gt;
&lt;li&gt;Jump to the program starting point in memory&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Assembler&lt;/strong&gt;- &lt;br&gt;
&lt;a href="https://www.quora.com/What-is-Assembler"&gt;Source&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An assembler is a program that converts assembly language source code into an executable program.&lt;/p&gt;

&lt;p&gt;This is comparable to a high-level computer language compiler. A compiler converts code into a program.&lt;/p&gt;

&lt;p&gt;However, assembly language is different because each line of code corresponds to a single low-level CPU OpCode.&lt;/p&gt;

</description>
      <category>java</category>
      <category>python</category>
      <category>architecture</category>
      <category>archlinux</category>
    </item>
    <item>
      <title>Interview OS (Part 1)</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Sun, 20 Dec 2020 13:35:02 +0000</pubDate>
      <link>https://forem.com/dubesar/interview-os-part-1-jj2</link>
      <guid>https://forem.com/dubesar/interview-os-part-1-jj2</guid>
      <description>&lt;p&gt;In this article, we will talk about the types of OS and how they can be asked in the interviews.&lt;/p&gt;

&lt;p&gt;The types of OS that we will discuss are:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Batched OS&lt;/li&gt;
&lt;li&gt;Time Sharing OS&lt;/li&gt;
&lt;li&gt;Distributed OS&lt;/li&gt;
&lt;li&gt;Network OS&lt;/li&gt;
&lt;li&gt;Real-Time OS&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Batched OS&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fqphs.fs.quoracdn.net%2Fmain-qimg-b4f284e32c384b097bb93849e695e6a6" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fqphs.fs.quoracdn.net%2Fmain-qimg-b4f284e32c384b097bb93849e695e6a6"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As you can see in the above image first the jobs with similar functions or similar types are segregated and put forward in queue and then the Operating system from time to time releases them to the batch system.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;So the question arises who will segregate the similar function jobs and how is it sent to the batches.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Firstly the operator has to segregate the jobs with similar functionality&lt;/li&gt;
&lt;li&gt;Secondly the batch system steps in the form of a Queue and similar jobs are sent in 
the form of a queue.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;What is the advantage of such an Operating System?&lt;/strong&gt; - The time required for the completion of the whole process is unknown generally but here, precisely for each queue it is known which can ultimately be taken as an advantage, Also if the job is very complex and will require a large amount of time for completion, then such process can be even completed in the absence of humans. Also, the Idle time of the OS is less. This system also gives the freedom of multiple users using the OS.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;What are the disadvantages?&lt;/strong&gt; - The batch system is really hard to debug. This system doesn't allow direct interaction between the user and the OS. Suppose an error occurs in one of the jobs of a batch. Then, all the remaining jobs get affected i.e; they have to wait until the error is resolved.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Time Sharing OS&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fqphs.fs.quoracdn.net%2Fmain-qimg-355f7bc22fdfb5de8a8063cc5395ac97.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fqphs.fs.quoracdn.net%2Fmain-qimg-355f7bc22fdfb5de8a8063cc5395ac97.webp"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As you can see in the above image that there are multiple users or what you can say is multiple jobs and thus called multitasking OS, is used to minimize time response and in turn making sure the maximizing usage of the processor ( which is the objective of multi-programming systems)&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In this OS, every user is given time of the CPU and equal time is allocated which is called quantum and once this time is over the OS switches to the next job.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What is the advantage of such an OS?&lt;/strong&gt;- They minimize the response time i.e; greater the response time. Since it's a time-sharing OS, the system is idle for very little time and each task gets equal time for execution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What is the disadvantage of such an OS?&lt;/strong&gt;- Maintaining Synchronization is a challenge and also security must be maintained&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Distributed OS&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fqphs.fs.quoracdn.net%2Fmain-qimg-fa4bf07c8dcd1a6726b53278ea5b0a16.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fqphs.fs.quoracdn.net%2Fmain-qimg-fa4bf07c8dcd1a6726b53278ea5b0a16.webp"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As you can see in the above image that different systems interact through a communication network like LAN or WAN to share the same resource and if needed provide the resource to the user.&lt;/li&gt;
&lt;li&gt;** One important point to note about distributed systems is that they are loosely-coupled i.e; hardware and software may communicate with each other but they need not depend upon each other.**&lt;/li&gt;
&lt;li&gt;The connected systems to the central system need not be of the same size and capacity.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The major advantage of such OS is that to access a file that is not actually present in the processor can be very easy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What are the advantages of such OS?&lt;/strong&gt;- Resources are being shared, computation is highly fast and durable, Reduced load on the host computer, Resources are easily accessible, System is scalable and a promising and better service to the user and failure of one of the processors don't affect the system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What are the disadvantages?&lt;/strong&gt;- Very complex structure and network security. Failure of the main host can lead to the failure of the system.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Network OS&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fqphs.fs.quoracdn.net%2Fmain-qimg-4c034890e5a0f8f4a1c7799c79025348.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fqphs.fs.quoracdn.net%2Fmain-qimg-4c034890e5a0f8f4a1c7799c79025348.webp"&gt;&lt;/a&gt; &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608349632355%2F9Lr5ddezm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1608349632355%2F9Lr5ddezm.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As you can see in the above image there needs to be a centralized system for employing such type of OS.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;One more important aspect of Network Operating Systems is that all the users are well aware of the underlying configuration, of all other users within the network, their individual connections, etc. and that’s why these computers are popularly known as tightly coupled systems.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What are the advantages of such OS?&lt;/strong&gt;- The entire central system is very much stabilized, The entire configuration can be done at the central system. New technology and hardware integration are very easy. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What are the disadvantages?&lt;/strong&gt;- Very costly system. Need for central location even for the smallest of the computation, Regular maintenance is required.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Real Time OS&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.polytechnichub.com%2Fwp-content%2Fuploads%2F2017%2F05%2FRTOS.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.polytechnichub.com%2Fwp-content%2Fuploads%2F2017%2F05%2FRTOS.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are two types of RTOS: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Hard RTOS:- Time constrained and strict and no delay acceptable&lt;/li&gt;
&lt;li&gt;Soft RTOS:- These are much less strict than Hard RTOS&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What are the advantages of such OS?&lt;/strong&gt;- Maximum usage of the system, task shifting in case of some issues with current running task or thread, more focus on running the current thread rather than the queue, good memory allocation system&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;What are the disadvantages?&lt;/strong&gt; - Very complex system, limited task execution, heavily embedded systems needed, having thread priority rather than switching tasks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  In the next, we will be going through some important OS terms needed to be known, till then subscribe to the newsletter so that you don't miss any updates!
&lt;/h3&gt;

</description>
      <category>aws</category>
      <category>linux</category>
      <category>java</category>
    </item>
    <item>
      <title>Creating a Virtual Environment in Python (Ubuntu)</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Wed, 16 Dec 2020 03:14:14 +0000</pubDate>
      <link>https://forem.com/dubesar/creating-a-virtual-environment-in-python-ubuntu-40ki</link>
      <guid>https://forem.com/dubesar/creating-a-virtual-environment-in-python-ubuntu-40ki</guid>
      <description>&lt;p&gt;Creating a virtual environment is really very easy in Ubuntu&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1:-
&lt;/h3&gt;

&lt;p&gt;First, we have to install the virtual environment using the following command:-&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo apt install python3-venv&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2:-
&lt;/h3&gt;

&lt;p&gt;From the previous step, you have installed the virtual environment on the system, now you have to create a project using it:-&lt;/p&gt;

&lt;p&gt;&lt;code&gt;python3 -m venv new-project&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3:-
&lt;/h3&gt;

&lt;p&gt;Now for activating the above virtual environment you just have to use:-&lt;/p&gt;

&lt;p&gt;&lt;code&gt;source new-project/bin/activate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You will see the following output:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;source &lt;/span&gt;new-project/bin/activate
&lt;span class="o"&gt;(&lt;/span&gt;my-project-env&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now just install whatever dependencies you want to install like any other library and work on the project.&lt;/p&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>SASS (Syntactically Awesome StyleSheets)- Basics (Part 2)</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Sat, 12 Dec 2020 10:38:17 +0000</pubDate>
      <link>https://forem.com/dubesar/sass-syntactically-awesome-stylesheets-basics-part-2-2k8o</link>
      <guid>https://forem.com/dubesar/sass-syntactically-awesome-stylesheets-basics-part-2-2k8o</guid>
      <description>&lt;p&gt;In the previous article, we covered some basics of SASS and defined the learning outcomes from the articles. We will cover the rest in this article.&lt;/p&gt;

&lt;p&gt;What we will learn:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;for loop&lt;/li&gt;
&lt;li&gt;each&lt;/li&gt;
&lt;li&gt;while&lt;/li&gt;
&lt;li&gt;Splitting styles into different files&lt;/li&gt;
&lt;li&gt;Extend properties of other class&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will finish off with all the basics in this article.&lt;/p&gt;

&lt;h3&gt;
  
  
  For Loop
&lt;/h3&gt;

&lt;p&gt;We can use for loop in Sass which is not possible in CSS, Let's say you have a particular naming convention of a class and it can be easily written using for loop, Sass gives us the power to write &lt;code&gt;for loops&lt;/code&gt;. Let's see how we can do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt; &lt;span class="nt"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;'text/scss'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;@for&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="n"&gt;from&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="m"&gt;6&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;.text-&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text-1"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;Hello&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text-2"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;Hello&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text-3"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;Hello&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text-4"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;Hello&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text-5"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;Hello&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see the last number in for loop is not taken into consideration. So be careful of using the loop extremes and parameters.&lt;/p&gt;

&lt;h3&gt;
  
  
  While Loop
&lt;/h3&gt;

&lt;p&gt;As in the previous example, we had the loop running from 1 to 6 and we had a common class naming convention which helped us apply the looping logic. Similarly we can do it here as well i.e. we can set the condition for the while loop. Let's see how we do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt; &lt;span class="nt"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;'text/scss'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="nt"&gt;i&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt;
  &lt;span class="k"&gt;@while&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt; &lt;span class="m"&gt;6&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nc"&gt;.text-&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="nt"&gt;i&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="nt"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="err"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text-1"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;Hello&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text-2"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;Hello&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text-3"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;Hello&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text-4"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;Hello&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text-5"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;Hello&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Each loop:
&lt;/h3&gt;

&lt;p&gt;Each loop works according to the values in the list that we want to iterate through. Let's say an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt; &lt;span class="nt"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text/scss"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="k"&gt;@each&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;$color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;-bg&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"blue-bg"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"black-bg"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"red-bg"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here you can see we have three div which can individually be colored accordingly using for loop.&lt;/p&gt;

&lt;h3&gt;
  
  
  Splitting Styles in different files
&lt;/h3&gt;

&lt;p&gt;This is fairly easy to do as this provides a structured format of the code and how we can split the codes accordingly.&lt;/p&gt;

&lt;p&gt;Let's say you have &lt;code&gt;component.scss&lt;/code&gt; file and you want to import it, you can simply use the @import directive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="n"&gt;component&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it and you are done importing the file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Extending properties of other class
&lt;/h3&gt;

&lt;p&gt;Let's say you want to have some properties to that of some other class, in CSS we had write that whole again but in Sass we can use the &lt;code&gt;@extend&lt;/code&gt; directive and directly use all the properties in other class or what we can say is inherit the properties of the class. Let's see how we can do this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.p&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;70px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.bp&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;@extend&lt;/span&gt; &lt;span class="err"&gt;.p;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;150px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see that we have inherited the properties of the upper class to the next class that we have written.&lt;/p&gt;

&lt;p&gt;This is all about the basics of Sass, I will be going through much deeper concepts of Sass later. Do stay tuned 😊&lt;/p&gt;

</description>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>SASS (Syntactically Awesome StyleSheets)- Basics (Part 1)</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Thu, 10 Dec 2020 05:53:41 +0000</pubDate>
      <link>https://forem.com/dubesar/sass-syntactically-awesome-stylesheets-basics-part-1-40k3</link>
      <guid>https://forem.com/dubesar/sass-syntactically-awesome-stylesheets-basics-part-1-40k3</guid>
      <description>&lt;p&gt;What we will learn:- &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Store Data in variables&lt;/li&gt;
&lt;li&gt; Nesting CSS with Sass&lt;/li&gt;
&lt;li&gt; Reusable CSS using Mixins&lt;/li&gt;
&lt;li&gt; if, else &lt;/li&gt;
&lt;li&gt; for loop&lt;/li&gt;
&lt;li&gt; each &lt;/li&gt;
&lt;li&gt; while&lt;/li&gt;
&lt;li&gt; Splitting styles into different files&lt;/li&gt;
&lt;li&gt; Extend properties of other class&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will keep the articles short so that we can make this a short series of articles. For this article, we will be going through the first 4 parts of the above learning objectives.&lt;/p&gt;

&lt;h3&gt;
  
  
  Storing Data in variables:-
&lt;/h3&gt;

&lt;p&gt;In CSS if we want to declare some style for a particular class we had to write all the particular styles for it though we might have the necessity to have some of the style properties the same for the next class. This gives rise to problems when the style needs to be changed in the future. &lt;/p&gt;

&lt;p&gt;CSS doesn't support variables for the above-mentioned problems. In Sass, we can mention a variable that can be used and assigned like any normal programming language.&lt;/p&gt;

&lt;p&gt;So how we do so? Let's dive into some code -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="nt"&gt;fonts&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;Arial&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;sans-serif&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="nt"&gt;headings-color&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;green&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;To&lt;/span&gt; &lt;span class="nt"&gt;use&lt;/span&gt; &lt;span class="nt"&gt;variables&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;fonts&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;headings-color&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can see how the variable is being used in place rather than using the actual property value.&lt;/p&gt;

&lt;h3&gt;
  
  
  Nesting CSS with Sass
&lt;/h3&gt;

&lt;p&gt;For any normal CSS, we don't have the unique way to nest CSS into other CSS, rather we follow writing each class and then defining the properties for each of them. For example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;nav&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;nav&lt;/span&gt; &lt;span class="nt"&gt;ul&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;list-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;nav&lt;/span&gt; &lt;span class="nt"&gt;ul&lt;/span&gt; &lt;span class="nt"&gt;li&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inline-block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For the above code, we have all the classes like ul and li nested in but the above code is the normal CSS code and doesn't follow the nesting architecture. If we were to write this code in Sass form we will have:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;nav&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="err"&gt;ul&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;list-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="err"&gt;li&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inline-block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Reusable CSS using Mixins:-
&lt;/h3&gt;

&lt;p&gt;This is similar to what we can say as defining the function and using it again and again with different parameters. This gives a lot of flexibility and control over the use of different styles and can reuse again and again. Let's see how we can do this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;@mixin&lt;/span&gt; &lt;span class="n"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;-webkit-border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;-moz-border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;-ms-border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;To&lt;/span&gt; &lt;span class="nt"&gt;reuse&lt;/span&gt; &lt;span class="nt"&gt;it&lt;/span&gt; &lt;span class="nt"&gt;again&lt;/span&gt;
&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;@include&lt;/span&gt; &lt;span class="err"&gt;border-radius(15px);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using if-else
&lt;/h3&gt;

&lt;p&gt;This works exactly similar to what we normally see in the if-else statements. Let's see how we can implement it in Sass&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@mixin&lt;/span&gt; &lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;@if&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="n"&gt;danger&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;@else&lt;/span&gt; &lt;span class="n"&gt;if&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="n"&gt;alert&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;@else&lt;/span&gt; &lt;span class="n"&gt;if&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="err"&gt;==&lt;/span&gt; &lt;span class="n"&gt;success&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;yellow&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;@else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In here we use mixins and we can just do normal if-else to make conditions on the styling we want to achieve.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stay Tuned for the next article we will go through the next 4 sections that we haven't yet covered 😊😊
&lt;/h2&gt;

</description>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Interview JS Part 4 - DOM and Layout Trees</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Mon, 30 Nov 2020 08:20:51 +0000</pubDate>
      <link>https://forem.com/dubesar/interview-js-part-4-dom-and-layout-trees-ibe</link>
      <guid>https://forem.com/dubesar/interview-js-part-4-dom-and-layout-trees-ibe</guid>
      <description>&lt;h3&gt;
  
  
  What is the DOM?
&lt;/h3&gt;

&lt;p&gt;At the most basic level, a website consists of an HTML document. The browser that you use to view the website is a program that interprets HTML and CSS and renders the style, content, and structure into the page that you see.&lt;/p&gt;

&lt;p&gt;In addition to parsing the style and structure of the HTML and CSS, the browser creates a representation of the document known as the Document Object Model. This model allows JavaScript to access the text content and elements of the website document as objects.&lt;/p&gt;

&lt;p&gt;Let's see an example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

  &amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Learning the DOM&amp;lt;/title&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt;Document Object Model&amp;lt;/h1&amp;gt;
  &amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above is the simple HTML code, and also you might be knowing that almost all the webpages have their structure defined in HTML. Now just inspect the element on this page and see the elements tab on the right-hand side of the browser. Whenever you hover over some line you can see some effect on the webpage depicting the element you are hovering at.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.digitalocean.com%2Farticles%2Feng_javascript%2Fdom%2Fthe-dom.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.digitalocean.com%2Farticles%2Feng_javascript%2Fdom%2Fthe-dom.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might also see the arrows in the HTML page on the elements tab. The HTML follows the parent-child relationship between the elements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-media-1.freecodecamp.org%2Fimages%2F3n6SPcMH0mmG6cFeB3SJBEA-9Yyfgp3xYZ7u" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-media-1.freecodecamp.org%2Fimages%2F3n6SPcMH0mmG6cFeB3SJBEA-9Yyfgp3xYZ7u"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Document Object
&lt;/h3&gt;

&lt;p&gt;A document object is a built-in object that has many properties and methods that we can use to access and modify websites.&lt;/p&gt;

&lt;p&gt;These include:- &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;getElementById()&lt;/li&gt;
&lt;li&gt;getElementsByClassName()&lt;/li&gt;
&lt;li&gt;getElementsByTagName()&lt;/li&gt;
&lt;li&gt;querySelector()&lt;/li&gt;
&lt;li&gt;querySelectorAll()&lt;/li&gt;
&lt;li&gt;Events&lt;/li&gt;
&lt;li&gt;clicks&lt;/li&gt;
&lt;li&gt;select&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Some inbuild methods to traverse the DOM include:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;.firstChild&lt;/li&gt;
&lt;li&gt;.nodeName&lt;/li&gt;
&lt;li&gt;.nodeValue&lt;/li&gt;
&lt;li&gt;.nodeType&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Elements include:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;.parentNode&lt;/li&gt;
&lt;li&gt;.firstElementChild&lt;/li&gt;
&lt;li&gt;.lastElementChild&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the next article, I will brief each and every DOM method from elements to manipulating the DOM.&lt;/p&gt;

&lt;p&gt;In the above example where we wrote the HTML code. Just go to the console and type in &lt;/p&gt;

&lt;p&gt;&lt;code&gt;document.body.style.backgroundColor = 'fuchsia';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And you can see the background color to be fuchsia. This is one of the examples of DOM manipulations&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stay Tuned for the next article&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Interview JS Part 3 -  Message Queue and Event Loop (Inspired by Philip Roberts)</title>
      <dc:creator>Sarvesh Dubey</dc:creator>
      <pubDate>Sat, 28 Nov 2020 05:47:25 +0000</pubDate>
      <link>https://forem.com/dubesar/interview-js-part-3-message-queue-and-event-loop-inspired-by-philip-roberts-422c</link>
      <guid>https://forem.com/dubesar/interview-js-part-3-message-queue-and-event-loop-inspired-by-philip-roberts-422c</guid>
      <description>&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: This article is a mixture of two articles and important points are extracted from both and some new are also added to make it complete&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://medium.com/front-end-weekly/javascript-event-loop-explained-4cd26af121d4" rel="noopener noreferrer"&gt;JS Event Loop&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.carbonfive.com/the-javascript-event-loop-explained/" rel="noopener noreferrer"&gt;JS Event Loop Explained&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this article, we will cover the following stuff:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;What the heck is the event loop?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How do JS works?  V8 engine, JS is single-threaded then how is a callback in JS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is JS? - A single-threaded non-blocking asynchronous concurrent language&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JS - It has a call stack, an event loop, a callback queue, and some other APIs and stuff. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Architecture of Chrome&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1600%2F0%2A6T6KIVRkN9nWb3QU.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1600%2F0%2A6T6KIVRkN9nWb3QU.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me go through different parts of the chrome (image above)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Heap&lt;/strong&gt;: Unstructured region of memory&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stack&lt;/strong&gt;: Represents the single-threaded call stack.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Browser of Web API&lt;/strong&gt;:  They are not part of the JavaScript language itself, rather they are built on top of the core JavaScript language, providing you with extra superpowers to use in your JavaScript code&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Go through this below example carefully&lt;/strong&gt;:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;A&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;B&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;C&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;//  Output&lt;/span&gt;
&lt;span class="c1"&gt;//  A&lt;/span&gt;
&lt;span class="c1"&gt;//  C&lt;/span&gt;
&lt;span class="c1"&gt;//  B&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1250%2F1%2A64BQlpR00yfDKsXVv9lnIg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1250%2F1%2A64BQlpR00yfDKsXVv9lnIg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The call to the main function is first pushed into the stack (as a frame). Then the browser pushes the first statement in the main function into the stack which is console.log(‘A’). This statement is executed and upon completion, that frame is popped out. Alphabet A is displayed in the console.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The next statement (setTimeout() with callback exec() and 0ms wait time) is pushed into the call stack and execution starts. setTimeout function uses a Browser API to delay a callback to the provided function. The frame (with setTimeout) is then popped out once the handover to the browser is complete (for the timer).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;console.log(‘C’) is pushed to the stack while the timer runs in the browser for the callback to the exec() function. In this particular case, as the delay provided was 0ms, the callback will be added to the message queue as soon as the browser receives it (ideally).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After the execution of the last statement in the main function, the main() frame is popped out of the call stack, thereby making it empty. For the browser to push any message from the queue to the call stack, the call stack has to be empty first. That is why even though the delay provided in the setTimeout() was 0 seconds, the callback to exec() has to wait till the execution of all the frames in the call stack is complete.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now the callback exec() is pushed into the call stack and executed. The alphabet C is displayed on the console. This is the event loop of javascript.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Another Example&lt;/strong&gt;:-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.carbonfive.com%2Fwp-content%2Fuploads%2F2013%2F10%2Fevent-loop.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.carbonfive.com%2Fwp-content%2Fuploads%2F2013%2F10%2Fevent-loop.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;foo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;changeColor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;burlywood&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;%[&lt;a href="https://www.youtube.com/watch?v=8aGhZQkoFbQ" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=8aGhZQkoFbQ&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;Thanks for reading follow the Interview JS series for more core concepts of JavaScript.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
  </channel>
</rss>
