<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aks</title>
    <description>The latest articles on DEV Community by Aks (@akanksha_9560).</description>
    <link>https://dev.to/akanksha_9560</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%2F54261%2F42b9562e-ec6b-4c2f-8aba-155812515831.jpg</url>
      <title>DEV Community: Aks</title>
      <link>https://dev.to/akanksha_9560</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/akanksha_9560"/>
    <language>en</language>
    <item>
      <title>Things I learned from Code reviews</title>
      <dc:creator>Aks</dc:creator>
      <pubDate>Tue, 13 Aug 2019 12:24:22 +0000</pubDate>
      <link>https://dev.to/akanksha_9560/things-i-learned-from-code-reviews-12f3</link>
      <guid>https://dev.to/akanksha_9560/things-i-learned-from-code-reviews-12f3</guid>
      <description>&lt;p&gt;We all know the importance of code reviews and how it helps to maintain code quality and establishes coding standards in the team.&lt;/p&gt;

&lt;p&gt;But I want to point out a different side of the coin and tell you how it helped me when I was starting in the Development field.&lt;/p&gt;

&lt;h1&gt;
  
  
  Code Quality
&lt;/h1&gt;

&lt;p&gt;As a junior dev in my first job, I did not know a lot about design patterns or javascript concepts. My mentors provided me with great knowledge of how I should use design patterns while writing any piece of code, no matter the language. They provided constructive feedback as to what sources I should refer to when solving different problems. &lt;/p&gt;

&lt;h1&gt;
  
  
  Knowledge Transfer
&lt;/h1&gt;

&lt;p&gt;Code reviews helped me get domain-specific knowledge, helped me learn how to structure code according to requirements. They helped me understand the product and how different parts of the system work together to give user experience.&lt;/p&gt;

&lt;h1&gt;
  
  
  Knowledge Dissemination
&lt;/h1&gt;

&lt;p&gt;Code reviews helped me and my team to share the knowledge about every piece of code. So nobody was the sole point of contact in case of emergencies. Everybody was a code owner of all of the code. This helped me a lot in gaining confidence in my code and my management skills during emergencies.&lt;/p&gt;

&lt;h1&gt;
  
  
  Art of Discussion
&lt;/h1&gt;

&lt;p&gt;Code reviews help to see the code from the view of business requirements. It helps beginners especially understand concepts of domain-driven design. It encourages them to research and to defend their design in front of code reviewers. &lt;/p&gt;

&lt;h1&gt;
  
  
  Forward Help
&lt;/h1&gt;

&lt;p&gt;One of the biggest problems I see in new devs is they do not have confidence in their code and sometimes are not able to express why they are using an approach over another. So, I and my friend have come up with an idea to help young devs. &lt;/p&gt;

&lt;p&gt;You can forward us your code and we would love to provide you with constructive feedback. We want forward the help we received when starting. Reach us out via email  &lt;a href="//mailto:akanksha.s9560@gmail.com"&gt;Akanksha Sharma&lt;/a&gt; and &lt;a href="//mailto:alicankaralar@gmail.com"&gt;Alican Karalar&lt;/a&gt; or twitter &lt;a href="https://twitter.com/Akanksha_9560"&gt;@Akanksha_9560&lt;/a&gt; and &lt;a href="https://twitter.com/alican_js"&gt;@alican_js&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codequality</category>
      <category>career</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Docker For Frontend Developers</title>
      <dc:creator>Aks</dc:creator>
      <pubDate>Thu, 02 May 2019 11:52:44 +0000</pubDate>
      <link>https://dev.to/akanksha_9560/docker-for-frontend-developers-1dk5</link>
      <guid>https://dev.to/akanksha_9560/docker-for-frontend-developers-1dk5</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This is short and simple guide of docker, useful for frontend developers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why should you use docker?
&lt;/h2&gt;

&lt;p&gt;Long long back when business needed other application DevOps team would go out and buy a server, without knowing performance requirements of the new apps. This would involve lot of guess work and wastage of capital and resources which could be used for other apps.&lt;/p&gt;

&lt;p&gt;Enter Virtual machines or VM, it allowed us to run multiple apps on same servers. but there is a drawback. Every VM needed entire OS to run. Every OS needs CPU, RAM etc to run, it needs patching and licensing, which in turn increases cost and resiliency.&lt;/p&gt;

&lt;p&gt;Google started using containers model long time ago to address shortcomings of VM model. Basically what container model means that multiple containers on same host uses same host, freeing up CPU, RAM which could be used elsewhere.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;But how does it helps us developers?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It ensures that the working environment is same for all developers and all servers i.e, production, staging and testing&lt;/p&gt;

&lt;p&gt;Anyone can setup the project in seconds, no need to mess with config, install libraries, setup dependencies etc.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In simple terms docker is a platform that enables us to &lt;strong&gt;develop, deploy, and run&lt;/strong&gt; applications with containers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s take a step back, what does container system look like physically and how is it different from VM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeg0o45wfrpni85xjh1d.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeg0o45wfrpni85xjh1d.png" alt="1.1 Difference between VM and docker" width="800" height="315"&gt;&lt;/a&gt;&lt;/p&gt;
1.1 Difference between VM and docker.



&lt;p&gt;As you can see host and it’s resources are shared in containers but not in Virtual Machine.&lt;/p&gt;

&lt;p&gt;With that out of the way, let’s dive.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use docker?
&lt;/h2&gt;

&lt;p&gt;For that we need to familiarise ourselves with certain terminology.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fcs6q2qn2m0zvc9s3geg9.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fcs6q2qn2m0zvc9s3geg9.png" alt="1.2 Visualisation of docker images and docker container" width="800" height="460"&gt;&lt;/a&gt;&lt;/p&gt;
1.2 Visualisation of docker images and docker container



&lt;p&gt;&lt;strong&gt;Docker image&lt;/strong&gt;: It is an executable file which contains cutdown operating system and all the libraries and configuration needed to run the application. It has multiple layers stacked on top of each other and represented as single object. A docker image is created using &lt;em&gt;docker file&lt;/em&gt;, we will get to that in a bit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker Container:&lt;/strong&gt; It is a running instance of docker image. there can be many containers running from same docker image.&lt;/p&gt;

&lt;h2&gt;
  
  
  Containerise simple Node.js App
&lt;/h2&gt;

&lt;p&gt;We would try to containerise very node.js simple app, and create a image:&lt;/p&gt;

&lt;h3&gt;
  
  
  Your Node.js App
&lt;/h3&gt;

&lt;p&gt;Let’s start by creating folder &lt;code&gt;my-node-app&lt;/code&gt; ,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir my-node-app  
cd my-node-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;let ‘s create a simple node server in &lt;code&gt;index.js&lt;/code&gt; and add following code there:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Load express module with `require` directive

var express = require('express')

var app = express()

//Define request response in root URL (/)  
app.get('/', function (req, res) {  
 res.send('Hello World!')  
})

//Launch listening server on port 8081  
app.listen(8081, function () {  
  console.log('app listening on port 8081!')  
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and save this file inside your &lt;code&gt;my-node-app&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;Now we create a &lt;code&gt;package.json&lt;/code&gt; file and add following code there:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; {

    "name": "helloworld",  
    "version": "1.0.0",  
    "description": "Dockerized node.js app",  
    "main": "index.js",  
    "author": "",  
    "license": "ISC",  
    "dependencies": {  
      "express": "^4.16.4"  
    }

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

&lt;/div&gt;



&lt;p&gt;At this point you don’t need express or npm installed in your host, because remember dockerfile handles setting up all the dependencies, lib and configurations.&lt;/p&gt;

&lt;h3&gt;
  
  
  DockerFile
&lt;/h3&gt;

&lt;p&gt;Let’s create dockerfile and save it inside our &lt;code&gt;my-node-app folder&lt;/code&gt;. This file has no extension and is named &lt;code&gt;Dockerfile&lt;/code&gt; . Let go ahead and add following code to our dockerfile.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Dockerfile  
    FROM node:8  
    WORKDIR /app  
    COPY package.json /app  
    RUN npm install  
    COPY . /app  
    EXPOSE 8081  
    CMD node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now what we are doing here:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;FROM node:8 &lt;/code&gt;— pulls node.js docker image from docker hub, which can be found here &lt;a href="https://medium.com/r/?url=https%3A%2F%2Fhub.docker.com%2F_%2Fnode%2F" rel="noopener noreferrer"&gt;https://hub.docker.com/_/node/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;WORKDIR /app&lt;/code&gt; -this sets working directory for our code in image, it is used by all the subsequent commands such as &lt;code&gt;COPY&lt;/code&gt; , &lt;code&gt;RUN&lt;/code&gt; and &lt;code&gt;CMD&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;COPY package.json /app&lt;/code&gt; -this copies our package.json from host &lt;code&gt;my-node-app&lt;/code&gt; folder to our image in &lt;code&gt;/app&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;RUN npm install&lt;/code&gt; — we are running this command inside our image to install dependencies (node_modules) for our app.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;COPY . /app &lt;/code&gt;— we are telling docker to copy our files from my-node-app folder and paste it to &lt;code&gt;/app&lt;/code&gt; in docker image.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;EXPOSE 8081&lt;/code&gt; — we are exposing a port on the container using this command. Why this port ? because in our server in index.js is listening on 8081. By default containers created from this image will ignore all the requests made to it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Build Docker Image
&lt;/h3&gt;

&lt;p&gt;Show time. Open terminal , go to your folder &lt;code&gt;my-node-app&lt;/code&gt; and type following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     # Build a image docker build -t &amp;lt;image-name&amp;gt; &amp;lt;relative-path-to-your-dockerfile&amp;gt;

    docker build -t hello-world .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates a &lt;code&gt;hello-world&lt;/code&gt; image on our host.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-t&lt;/code&gt; is used to give a name to our image which is &lt;strong&gt;hello-world&lt;/strong&gt; here.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.&lt;/code&gt; is the relative path to docker file, since we are in folder &lt;code&gt;my-node-app&lt;/code&gt; we used dot to represent path to docker file.&lt;/p&gt;

&lt;p&gt;You will see an output on your command line something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Sending build context to Docker daemon  4.096kB  
    Step 1/7 : FROM node:8  
     ---&amp;gt; 4f01e5319662  
    Step 2/7 : WORKDIR /app  
     ---&amp;gt; Using cache  
     ---&amp;gt; 5c173b2c7b76  
    Step 3/7 : COPY package.json /app  
     ---&amp;gt; Using cache  
     ---&amp;gt; ceb27a57f18e  
    Step 4/7 : RUN npm install  
     ---&amp;gt; Using cache  
     ---&amp;gt; c1baaf16812a  
    Step 5/7 : COPY . /app  
     ---&amp;gt; 4a770927e8e8  
    Step 6/7 : EXPOSE 8081  
     ---&amp;gt; Running in 2b3f11daff5e  
    Removing intermediate container 2b3f11daff5e  
     ---&amp;gt; 81a7ce14340a  
    Step 7/7 : CMD node index.js  
     ---&amp;gt; Running in 3791dd7f5149  
    Removing intermediate container 3791dd7f5149  
     ---&amp;gt; c80301fa07b2  
    Successfully built c80301fa07b2  
    Successfully tagged hello-world:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see it ran the steps in our docker file and output a docker image. When you try it first time it will take a few minutes, but from next time it will start to use the cache and build much faster and output will be like the one shown above. Now, try following command in your terminal to see if your image is there or not :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Get a list of images on your host 
    docker images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it should have a list of images in your host. something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    REPOSITORY    TAG      IMAGE ID      CREATED         SIZE  
    hello-world   latest   c80301fa07b2  22 minutes ago  896MB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Run Docker Container
&lt;/h3&gt;

&lt;p&gt;With our images created we can spin up a container from this image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Default command for this is docker container run &amp;lt;image-name&amp;gt;  
    docker container run -p 4000:8081  hello-world
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command is used to create and run a docker container.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;-p 4000:8081&lt;/code&gt;— this is publish flag, it maps host port 4000 to container port 8081 which we opened through expose command in dockerfile. Now all the requests to host port 4000 will be listened by container port 8081.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;hello-world&lt;/code&gt; — this is the name we gave our image earlier when we ran docker-build command.&lt;/p&gt;

&lt;p&gt;You will receive some output like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    app listening on port 8081!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to enter your container and mount a bash terminal to it you can run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Enter the container
    docker exec -ti &amp;lt;container id&amp;gt; /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In order to check if container is running or not, open another terminal and type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    docker ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see your running container like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     CONTAINER ID    IMAGE        COMMAND                  CREATED    
    `&amp;lt;container id&amp;gt;`  hello-world  "/bin/sh -c 'node in…"   11 seconds ago

    STATUS              PORTS                    NAMES  
    Up 11 seconds       0.0.0.0:4000-&amp;gt;8081/tcp   some-random-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It means our container with id &lt;code&gt;&amp;lt;container id&amp;gt;&lt;/code&gt; created from hello-world image, is up and running and listening to port 8081.&lt;/p&gt;

&lt;p&gt;Now our small Node.js app is completely containerised. You can run &lt;a href="http://localhost:4000/" rel="noopener noreferrer"&gt;http://localhost:4000/&lt;/a&gt; on your browser and you should see something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwv6aw1lpwpb752ly6lb.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwv6aw1lpwpb752ly6lb.png" alt="1.3 Containerised Node.js App" width="800" height="228"&gt;&lt;/a&gt;&lt;/p&gt;
1.3 Containerised Node.js App



&lt;p&gt;Voilà, you have containerised your first app.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>docker</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Need Opinions</title>
      <dc:creator>Aks</dc:creator>
      <pubDate>Thu, 28 Mar 2019 12:32:48 +0000</pubDate>
      <link>https://dev.to/akanksha_9560/need-opinions-4h6n</link>
      <guid>https://dev.to/akanksha_9560/need-opinions-4h6n</guid>
      <description>&lt;p&gt;Need opinions:&lt;br&gt;
what is better in JS context composition or inheritance? What should be used when?&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>functional</category>
      <category>help</category>
    </item>
    <item>
      <title>Beginner's guide to SASS</title>
      <dc:creator>Aks</dc:creator>
      <pubDate>Sat, 21 Apr 2018 09:39:18 +0000</pubDate>
      <link>https://dev.to/akanksha_9560/beginners-guide-to-sass-8lh</link>
      <guid>https://dev.to/akanksha_9560/beginners-guide-to-sass-8lh</guid>
      <description>&lt;h1&gt;
  
  
  Beginner’s guide to SASS
&lt;/h1&gt;

&lt;p&gt;Let’s face it, writing css is messy. More so when reviewing the code which other people have written. I find SASS is the answer to that. It helps you to write clean code which is readable.&lt;/p&gt;

&lt;p&gt;Let’s jump into it. Let’s create a simple HTML which has nested div’s , hover, focus, repeated CSS properties, you know standard HTML we face in daily life.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It is important to understand why are we using classses &lt;strong&gt;parent1__link1&lt;/strong&gt;. It is a part of BEM (Block Element Modifier) methodology where **parent1 **is block and **link1 **is element. BEM follows **simple **rules to name and organise your CSS and gives everyone on a project a declarative syntax which they can use so that they’re on the same page.&lt;br&gt;
You can read about it &lt;a href="http://getbem.com/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&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-images-1.medium.com%2Fmax%2F2000%2F1%2AzanUCVgJsz7WDMu1wq00YA.jpeg" 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-images-1.medium.com%2Fmax%2F2000%2F1%2AzanUCVgJsz7WDMu1wq00YA.jpeg" alt="Example HTML Markup"&gt;&lt;/a&gt;&lt;em&gt;Example HTML Markup&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Variables
&lt;/h2&gt;

&lt;p&gt;Let’s start with writing css for header. Pretty simple stuff, background-color and color properties.&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-images-1.medium.com%2Fmax%2F2702%2F1%2AVU4eN80-fTIESW6IDJsNCw.jpeg" 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-images-1.medium.com%2Fmax%2F2702%2F1%2AVU4eN80-fTIESW6IDJsNCw.jpeg" alt="CSS for header class"&gt;&lt;/a&gt;&lt;em&gt;CSS for header class&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here with help of SASS we can change &lt;em&gt;**color codes to variable *&lt;/em&gt;&lt;em&gt;so that it can be reused . So, let’s create variables for our color codes (you can use &lt;a href="http://www.color-blindness.com/color-name-hue/" rel="noopener noreferrer"&gt;this &lt;/a&gt;to come up with names for color variables) using *&lt;/em&gt;&lt;em&gt;$ (this is important to create variables in SASS). *&lt;/em&gt;*Our new css for header would look like this. We can also use variable for many things padding, margins, color basically anything you want to reuse.&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-images-1.medium.com%2Fmax%2F2000%2F1%2AZOfjSD9byucKBwzAK6ZTAw.jpeg" 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-images-1.medium.com%2Fmax%2F2000%2F1%2AZOfjSD9byucKBwzAK6ZTAw.jpeg" alt="Use variable for reusable properties"&gt;&lt;/a&gt;&lt;em&gt;Use variable for reusable properties&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Imports
&lt;/h2&gt;

&lt;p&gt;To make css even more modular, SASS provides import functionality. We can put all the color names, mixins, common styles in different files and import them. So, let’s create a &lt;em&gt;_color.scss&lt;/em&gt; file.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note the name of** _color.scss** file. This is called a &lt;strong&gt;partial file&lt;/strong&gt; meaning this file contains little snippets of CSS that you can include in other Sass files. The **underscore **lets SASS know that the file is only a partial file and that it should not be generated into a CSS file&lt;/p&gt;
&lt;/blockquote&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-images-1.medium.com%2Fmax%2F2672%2F1%2AFdoOFhPo6WFLgJKVrrQE6Q.jpeg" 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-images-1.medium.com%2Fmax%2F2672%2F1%2AFdoOFhPo6WFLgJKVrrQE6Q.jpeg" alt="_color.scss file"&gt;&lt;/a&gt;&lt;em&gt;_color.scss file&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And we can import this file in our main scss file. using command&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;@import ‘./_color.scss’&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;and continue using color variables same way as depicted above.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nesting
&lt;/h2&gt;

&lt;p&gt;Next we jump to **&lt;em&gt;parent1 *&lt;/em&gt;(please refer HTML Markup above)*and it’s children.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Problem statement 1&lt;/strong&gt;: Write CSS for &lt;em&gt;**parent1 *&lt;/em&gt;&lt;em&gt;and *&lt;/em&gt;&lt;em&gt;parent1__link1&lt;/em&gt;**
&lt;/h3&gt;

&lt;p&gt;For the this problem, we will use &lt;em&gt;**&amp;amp; *&lt;/em&gt;&lt;em&gt;for concatenation of classes *&lt;/em&gt;&lt;em&gt;parent1&lt;/em&gt;** and &lt;strong&gt;&lt;em&gt;parent1__link1&lt;/em&gt;&lt;/strong&gt;. Please refer to image below (pay attention to use of variables here as well)&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-images-1.medium.com%2Fmax%2F2198%2F1%2ANm2tjjwx9BfSQGRp7lwagw.jpeg" 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-images-1.medium.com%2Fmax%2F2198%2F1%2ANm2tjjwx9BfSQGRp7lwagw.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Problem statement 2&lt;/strong&gt;: Write &lt;em&gt;**hover *&lt;/em&gt;&lt;em&gt;and *&lt;/em&gt;&lt;em&gt;after *&lt;/em&gt;*classes for &lt;a&gt; element
&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;For this problem we will concatenate pseudo classes and elements to &lt;strong&gt;parent1__link1 **using&lt;/strong&gt; &amp;amp;**.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Make a note: pseudo classes are concatenated using &lt;strong&gt;&lt;em&gt;&amp;amp;:&lt;/em&gt;&lt;/strong&gt; and pseudo elements are concatenated with &lt;strong&gt;&lt;em&gt;&amp;amp;::&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Comprehensive list of pseudo classes and pseudo link is available &lt;a href="http://www.growingwiththeweb.com/2012/08/pseudo-classes-vs-pseudo-elements.html" rel="noopener noreferrer"&gt;here&lt;/a&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%2Fcdn-images-1.medium.com%2Fmax%2F2014%2F1%2AH7oc3zJlyvc39-oUAHp2HA.jpeg" 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-images-1.medium.com%2Fmax%2F2014%2F1%2AH7oc3zJlyvc39-oUAHp2HA.jpeg" alt="Use of Pseudo classes in SASS"&gt;&lt;/a&gt;&lt;em&gt;Use of Pseudo classes in SASS&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Mixins
&lt;/h2&gt;

&lt;p&gt;As described above we have written CSS for parent1. We will write same CSS for parent two as well.&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-images-1.medium.com%2Fmax%2F2320%2F1%2AoU7OU3td-wXpAebfSxQc5Q.jpeg" 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-images-1.medium.com%2Fmax%2F2320%2F1%2AoU7OU3td-wXpAebfSxQc5Q.jpeg" alt="complete css file with styles for parent1 and parent2"&gt;&lt;/a&gt;&lt;em&gt;complete css file with styles for parent1 and parent2&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As we can see in above file, parent1 and parent2 share many common css properties. We could make this css cleaner, simpler and more readable using *MIXINS. *Here is how mixin works:&lt;/p&gt;

&lt;p&gt;We create a custom common style using &lt;strong&gt;&lt;em&gt;@mixin&lt;/em&gt;&lt;/strong&gt; keyword like depicted in image below. It contains all the property that is common to both parent1 and parent2.&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-images-1.medium.com%2Fmax%2F2088%2F1%2AfcGfQnkhC5CFpFsd9AS9UQ.jpeg" 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-images-1.medium.com%2Fmax%2F2088%2F1%2AfcGfQnkhC5CFpFsd9AS9UQ.jpeg" alt="Mixin for common style of parent"&gt;&lt;/a&gt;&lt;em&gt;Mixin for common style of parent&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Next, we include the mixin in our parent styles.&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-images-1.medium.com%2Fmax%2F2706%2F1%2AjGmb-5lw_Nfc4XQBRJ3Djw.jpeg" 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-images-1.medium.com%2Fmax%2F2706%2F1%2AjGmb-5lw_Nfc4XQBRJ3Djw.jpeg" alt="Usage of Mixins"&gt;&lt;/a&gt;&lt;em&gt;Usage of Mixins&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here, I have created mixin for both &lt;em&gt;link style&lt;/em&gt; and &lt;em&gt;parent style&lt;/em&gt;. It makes code much more cleaner and readable.&lt;/p&gt;

&lt;p&gt;This is a basic guide to get started with SASS. Of course, SASS provides great variety of functionalities that can be used to make your life easier when writing CSS. You can refer to full guide for SASS &lt;a href="https://sass-lang.com/guide" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>sass</category>
      <category>css</category>
    </item>
    <item>
      <title>What kind of coding standards do you follow when writing HTML?</title>
      <dc:creator>Aks</dc:creator>
      <pubDate>Fri, 30 Mar 2018 08:23:27 +0000</pubDate>
      <link>https://dev.to/akanksha_9560/what-kind-of-coding-standards-do-you-follow-when-writing-html-37j8</link>
      <guid>https://dev.to/akanksha_9560/what-kind-of-coding-standards-do-you-follow-when-writing-html-37j8</guid>
      <description>&lt;p&gt;What kind of coding standards do you follow when writing HTML?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>html</category>
      <category>codingstandards</category>
    </item>
    <item>
      <title>What is better for SSR in Vue.js Redux or Vuex?</title>
      <dc:creator>Aks</dc:creator>
      <pubDate>Mon, 19 Mar 2018 04:52:58 +0000</pubDate>
      <link>https://dev.to/akanksha_9560/what-is-better-for-ssr-in-vuejs-redux-or-vuex-2f5k</link>
      <guid>https://dev.to/akanksha_9560/what-is-better-for-ssr-in-vuejs-redux-or-vuex-2f5k</guid>
      <description>&lt;p&gt;What in your experience is better for server side rendering in Vue.js? Redux or Vue.js?&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Nevertheless, Akanksha Sharma Coded</title>
      <dc:creator>Aks</dc:creator>
      <pubDate>Thu, 08 Mar 2018 06:41:45 +0000</pubDate>
      <link>https://dev.to/akanksha_9560/nevertheless-akanksha-sharma-coded--12</link>
      <guid>https://dev.to/akanksha_9560/nevertheless-akanksha-sharma-coded--12</guid>
      <description>&lt;h2&gt;
  
  
  I began to code because...
&lt;/h2&gt;

&lt;p&gt;I am not a computer science graduate, I am(was?) an electrical engineer, heck I did not even own a computer until I got in second year of college (small town in middle of nowhere in 90's). Frankly, I started to code to pay my bills.&lt;br&gt;
My plan was to continue my computer gig until I get a job in my field.&lt;/p&gt;

&lt;p&gt;But after I saw the beauty of coding field, I felt I found my calling. Everyday is a new challenge. You experience joy of building new things everyday.&lt;br&gt;
I am very fortunate that I got a job as developer in start of my career so that I would know this is where I was meant to be.&lt;/p&gt;

&lt;h2&gt;
  
  
  I continue to code because
&lt;/h2&gt;

&lt;p&gt;Despite receiving half pay than my male counterparts, despite being ridiculed by client because women cannot be good enough developers, I love coding . In the words of my mentor, just focus on skills, success will come eventually. &lt;/p&gt;

&lt;h2&gt;
  
  
  I'm an expert at...
&lt;/h2&gt;

&lt;p&gt;Front end Technologies. My first job was as a junior developer to solve bugs for a web application. Wanting to learn more about software development I joined a startup where I worked on several applications from scratch as single person team.&lt;br&gt;
Currently I am at a great company with great mentors who always encourage me to strive for excellence. In last 3+ years I have worked on all major front end technologies React.js, Angular, Vue.js, Cycle,js. &lt;br&gt;
I am currently dabbing in node.js.&lt;/p&gt;

&lt;h2&gt;
  
  
  I recently overcame...
&lt;/h2&gt;

&lt;p&gt;The fear of writing online. I published two technical blogs till now and received amazing response from online community.&lt;/p&gt;

&lt;h2&gt;
  
  
  My advice for allies to support women and non-binary folks who code is....
&lt;/h2&gt;

&lt;p&gt;No matter what happens do not give up. Sounds a little bit cliche. &lt;br&gt;
 But seriously you got less pay, are being discriminated on basis of gender,&lt;br&gt;
 don't ever stop learning, honing your skills. In the words of Douglas Malloch:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`If you can't be a highway then just be a trail,`
`If you can't be the sun be a star`
`It isn't by size that you win or you fail,`
`Be the best of whatever you are!`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>wecoded</category>
    </item>
    <item>
      <title>Why not to use setInterval</title>
      <dc:creator>Aks</dc:creator>
      <pubDate>Mon, 19 Feb 2018 09:20:06 +0000</pubDate>
      <link>https://dev.to/akanksha_9560/why-not-to-use-setinterval--2na9</link>
      <guid>https://dev.to/akanksha_9560/why-not-to-use-setinterval--2na9</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Recently, I came across a requirement where I had to call a function repeatedly after specific time interval, like sending ajax call at every 10 seconds. Sure, best option seems as &lt;code&gt;setInterval&lt;/code&gt;, but it blew up my face like a cracker :)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In order to understand why setInterval is evil we need to keep in mind a fact that javascript is essentially single threaded, meaning it will not perform more than one operation at a time.&lt;/p&gt;

&lt;p&gt;In cases when functions takes longer than delay mentioned in &lt;code&gt;setInterval&lt;/code&gt; (like ajax call, which might it prevent from completing on time), we will find that either functions have no breathing room or setInterval breaks it's rhythm.&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;fakeCallToServer&lt;/span&gt; &lt;span class="o"&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="nx"&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="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;returning from server&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;toLocaleTimeString&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;4000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;



    &lt;span class="nx"&gt;setInterval&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;insideSetInterval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;toLocaleTimeString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;insideSetInterval&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;insideSetInterval&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="nx"&gt;fakeCallToServer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//insideSetInterval 14:13:47&lt;/span&gt;
&lt;span class="c1"&gt;//insideSetInterval 14:13:49&lt;/span&gt;
&lt;span class="c1"&gt;//insideSetInterval 14:13:51&lt;/span&gt;
&lt;span class="c1"&gt;//returning from server 14:13:51&lt;/span&gt;
&lt;span class="c1"&gt;//insideSetInterval 14:13:53&lt;/span&gt;
&lt;span class="c1"&gt;//returning from server 14:13:53 &lt;/span&gt;
&lt;span class="c1"&gt;//insideSetInterval 14:13:55&lt;/span&gt;
&lt;span class="c1"&gt;//returning from server 14:13:55&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Try above code snippets in your console&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As you can see from printed console.log statement that &lt;code&gt;setInterval&lt;/code&gt; keeps on sending ajax calls relentlessly without caring previous call has returned or not.&lt;br&gt;
This can queue up a lot of requests at once on the server.&lt;/p&gt;

&lt;p&gt;Now, let's try a synchronous operation in &lt;code&gt;setInterval&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;fakeTimeIntensiveOperation&lt;/span&gt; &lt;span class="o"&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="k"&gt;for&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;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;50000000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="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;random&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;insideTimeTakingFunction&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;toLocaleTimeString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;insideTimeTakingFunction&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;insideTimeTakingFunction&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;timer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;setInterval&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;insideSetInterval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;toLocaleTimeString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;insideSetInterval&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;insideSetInterval&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nx"&gt;fakeTimeIntensiveOperation&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;counter&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="p"&gt;{&lt;/span&gt;
    &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nx"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timer&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;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//insideSetInterval 13:50:53&lt;/span&gt;
&lt;span class="c1"&gt;//insideTimeTakingFunction 13:50:55&lt;/span&gt;
&lt;span class="c1"&gt;//insideSetInterval 13:50:55 &amp;lt;---- not called after 1s&lt;/span&gt;
&lt;span class="c1"&gt;//insideSetInterval 13:50:56&lt;/span&gt;
&lt;span class="c1"&gt;//insideSetInterval 13:50:57&lt;/span&gt;
&lt;span class="c1"&gt;//insideSetInterval 13:50:58&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;We see here when &lt;code&gt;setInterval&lt;/code&gt; encounters time intensive operation, it does either of two things, a) try to get on track or b) create new rhythm. Here on chrome it creates a new rhythm.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In case of asynchronous operations, &lt;code&gt;setTimeInterval&lt;/code&gt; will create long queue of requests which will be very counterproductive.&lt;br&gt;
In case of time intensive synchronous operations, &lt;code&gt;setTimeInterval&lt;/code&gt; may break the rhythm.&lt;br&gt;
Also, if any error occurs in setInterval code block, it will not stop execution but keeps on running faulty code. Not to mention they need a &lt;code&gt;clearInterval&lt;/code&gt; function to stop it.&lt;br&gt;
Alternatively, you can use &lt;code&gt;setTimeout&lt;/code&gt; recursively in case of time sensitive operations.&lt;/p&gt;

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