<?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: Shreyas Pahune</title>
    <description>The latest articles on DEV Community by Shreyas Pahune (@shreyazz).</description>
    <link>https://dev.to/shreyazz</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%2F544828%2F55179764-636c-4651-a1e1-348e62ae5d42.jpg</url>
      <title>DEV Community: Shreyas Pahune</title>
      <link>https://dev.to/shreyazz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shreyazz"/>
    <language>en</language>
    <item>
      <title>All about design systems</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Wed, 23 Oct 2024 20:50:09 +0000</pubDate>
      <link>https://dev.to/shreyazz/all-about-design-systems-542a</link>
      <guid>https://dev.to/shreyazz/all-about-design-systems-542a</guid>
      <description>&lt;h2&gt;
  
  
  What is a good design
&lt;/h2&gt;

&lt;p&gt;Good design makes complex product / technology accessible and usable for a huge set of users. It helps to reduce the cognitive load of finding new features or using existing features in a product, hence making the user more productive. &lt;/p&gt;

&lt;p&gt;An essential KPI for a product has to be it’s retention and the ability of it to streamline the tasks for the user and make the user feel more organized, which essentially is a objective of a good design. &lt;/p&gt;

&lt;p&gt;Design is all about problem solving. Identification of the pain point of the user, researching, and iterative testing is what makes a product highly usable. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why design systems exists
&lt;/h2&gt;

&lt;p&gt;So as the name suggests design system is a comprehensive set of principles, guidelines and framework , to create a consistent and cohesive design. &lt;/p&gt;

&lt;p&gt;A design system standardizes the UI components and visual style across teams to eliminate the inconsistency between the design, and eventually the final product.&lt;/p&gt;

&lt;p&gt;Design system aids collaboration across various teams, such as design, development, marketing and product by creating a unified framework which is understandable to everyone. &lt;/p&gt;

&lt;p&gt;It fosters the alignment between the design and development team, by offering a well documented framework and structure ensuring that what gets built is matching with the designer’s idea. &lt;/p&gt;

&lt;h2&gt;
  
  
  Establishing core design principles
&lt;/h2&gt;

&lt;p&gt;Though sounds very superficial, but establishing the core design    principles in the design system is utmost necessary, eventually the core will give you the ‘why’ behind the design. It clarifies the brand identity and the product’s vision. &lt;/p&gt;

&lt;p&gt;Whether creating new components or adding functionality to the existing ones, teams can fall back upon the core to make sure that the product remains on the right track and adheres to the correct vision.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fv3n4omhmq979p6m778j5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fv3n4omhmq979p6m778j5.png" alt="Image description" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a unified visual language
&lt;/h2&gt;

&lt;p&gt;After laying down the core principles, designers have a deliberate choice to make, which is going to shape how a new user experiences and interprets the brand.&lt;/p&gt;

&lt;p&gt;Choosing typography, colors and other important design elements is the essence of the product. Some of the key design elements are &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Typography

&lt;ul&gt;
&lt;li&gt;Fonts are chosen based on how easy and appealing are they going to look on almost all sizes of screen. &lt;/li&gt;
&lt;li&gt;From a development point of view, web friendly fonts are chosen to ensure the performance and the load times are minimal. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Colors

&lt;ul&gt;
&lt;li&gt;Aesthetics and identity of the brand are the factors of colors decisions. &lt;/li&gt;
&lt;li&gt;The primary, secondary and neutral colors are chosen and then used in elements like buttons, toggles, headers etc..&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Spacing

&lt;ul&gt;
&lt;li&gt;Another aspect which is overlooked is spacing as it plays the crucial role of defining the gap between components hence maintinng a cohesive structure. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fkdvp9kqa39psnr4uz2fx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fkdvp9kqa39psnr4uz2fx.png" alt="Image description" width="442" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The design system has to be organized and accessible. It should include the basics from ‘why’ which is the core principle to the very detailed component design which is the unified visual language. It should also be scalable and collaborative in nature.  &lt;/p&gt;

&lt;p&gt;Though the design is usually prepared on Figma or other tools like it, products like storybook and GitBook provide an amazing arsenal of tools to document the whole structure. &lt;/p&gt;




</description>
      <category>webdev</category>
      <category>design</category>
      <category>designsystem</category>
      <category>ui</category>
    </item>
    <item>
      <title>All about Jamstack</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Tue, 06 Sep 2022 09:36:49 +0000</pubDate>
      <link>https://dev.to/shreyazz/all-about-jamstack-4065</link>
      <guid>https://dev.to/shreyazz/all-about-jamstack-4065</guid>
      <description>&lt;p&gt;Hey everyone, in this blog we’ll be learning about &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is Jamstack?&lt;/li&gt;
&lt;li&gt;Benefits of Jamstack.&lt;/li&gt;
&lt;li&gt;Approach towards a Jamstack project.&lt;/li&gt;
&lt;li&gt;Jamstack site generators.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So let's get started ✨.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Jamstack?
&lt;/h2&gt;

&lt;p&gt;Jamstack is a system to build fast, lightweight web apps with minimal efforts. &lt;/p&gt;

&lt;p&gt;Jamstack is powered by &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;li&gt;APIs&lt;/li&gt;
&lt;li&gt;Markdown&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is a method to deliver static websites to the user with ease of development. Instead of serving dynamic content using a huge backend, dynamic parts of the websites are powered by APIs. This makes the website snappy and fast as the JavaScript shipped to the user is reduced. &lt;/p&gt;

&lt;p&gt;The website's static part is stored in a CDN so the website will be loaded swiftly. Using this technique we can divide our project into small islands in which we can add JavaScript to some of the island thus resulting in lighter websites. This technique is called island architecture. &lt;/p&gt;

&lt;h2&gt;
  
  
  How does Jamstack handle backend functionality?
&lt;/h2&gt;

&lt;p&gt;Backend is a piece of code that runs on a server without exposing itself to the user. So to handle the backend functionality, Jamstack uses APIs through which we can fetch and send data to the server, which will further send us the computed data.&lt;/p&gt;

&lt;p&gt;We can make our custom APIs for niche tasks using any backend framework like ExpressJS and use them in our web apps. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why should we use Jamstack?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;b&gt;Swiftness&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The website can be blazingly fast as the majority of the content will be statically served with minimal JavaScript shipped to the user.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;b&gt;Scalablity&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Since the backend/API is developed independently, scaling the website wouldn't be a tedious task, and due to the fast speed, heavy traffic can be managed smoothly.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;b&gt;Developer Experience&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;People always give importance to the user experience (UX), but very few folks pay attention to the developer experience (DX). Using Jamstack web apps can be easily developed with a straight-forward approach.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Approach towards a Jamstack project.
&lt;/h2&gt;

&lt;p&gt;There is a very straight-forward approach to be followed while developing a project using Jamstack.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Divide the project into islands. &lt;/li&gt;
&lt;li&gt;Use HTML/CSS for static parts/islands.&lt;/li&gt;
&lt;li&gt;Hydrate the dynamic islands with JavaScript.&lt;/li&gt;
&lt;li&gt;Use APIs to build dynamic components.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Jamstack Generators
&lt;/h2&gt;

&lt;p&gt;There are a ton of generators for Jamstack. Here are some static site generators for Jamstack sites. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://astro.build/" rel="noopener noreferrer"&gt;Astro&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.11ty.dev/" rel="noopener noreferrer"&gt;Eleventy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gohugo.io/" rel="noopener noreferrer"&gt;Hugo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.gatsbyjs.com/" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you for reading the blog, hope it was helpful. &lt;br&gt;
Until next time 🙌🏻. &lt;/p&gt;

</description>
      <category>jamstack</category>
      <category>javascript</category>
      <category>api</category>
      <category>markdown</category>
    </item>
    <item>
      <title>An extensive guide to build your NPM package and publish it.</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Thu, 23 Jun 2022 21:31:15 +0000</pubDate>
      <link>https://dev.to/shreyazz/an-extensive-guide-to-building-your-npm-package-and-publishing-it-29k3</link>
      <guid>https://dev.to/shreyazz/an-extensive-guide-to-building-your-npm-package-and-publishing-it-29k3</guid>
      <description>&lt;p&gt;Hey folks, I hope you all are doing great. I've been building APIs and backends using &lt;code&gt;NodeJS&lt;/code&gt; and &lt;code&gt;ExpressJS&lt;/code&gt; for a while now and the one thing that I find most tedious is setting up the project.&lt;/p&gt;

&lt;p&gt;It includes: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Making directories like:

&lt;ul&gt;
&lt;li&gt;Middlewares&lt;/li&gt;
&lt;li&gt;Routes&lt;/li&gt;
&lt;li&gt;Database&lt;/li&gt;
&lt;li&gt;Models&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Setting up the boilerplate code in the index.js or the server.js file. &lt;/li&gt;

&lt;li&gt;Making .env  files and storing the secrets. &lt;/li&gt;

&lt;li&gt;Installing usually used packages like:

&lt;ul&gt;
&lt;li&gt;CORS&lt;/li&gt;
&lt;li&gt;ExpressJS&lt;/li&gt;
&lt;li&gt;JWT&lt;/li&gt;
&lt;li&gt;BcryptJS&lt;/li&gt;
&lt;li&gt;DOTENV&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;We are going to make this whole process happen with just one command. &lt;/p&gt;

&lt;h2&gt;
  
  
  What are we going to build?
&lt;/h2&gt;

&lt;p&gt;We are going to build a backend builder which lets us create the necessary folders, files and initialise the server with a basic get route. It will also install all the packages required for the server to work. So let's get started. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step-1 : Making NPM Account
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Make an account on NPM and login to the account. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step-2 :  Setting up the project
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Make an empty directory/folder. &lt;/li&gt;
&lt;li&gt;Create a js file named as &lt;code&gt;bin.js&lt;/code&gt; in the folder.&lt;/li&gt;
&lt;li&gt;Run npm init in that empty folder and set the entry point as &lt;code&gt;bin.js&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;This will create a package.json file.&lt;/li&gt;
&lt;li&gt;Modify that file according to the below image. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fj2580bfyc01uuifodmbu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fj2580bfyc01uuifodmbu.png" alt="package.json image" width="800" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Inside the &lt;code&gt;bin.js&lt;/code&gt; file import these three packages.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cp"&gt;#!/usr/bin/env node
&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;process&lt;/span&gt;&lt;span class="dl"&gt;"&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;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;"&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;child_process&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;child_process&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;We do not have to download these packages as they are inbuilt in NodeJS. &lt;/li&gt;
&lt;li&gt;We use shebang code &lt;code&gt;(#!/usr/bin/env node)&lt;/code&gt; to tell the kernel which interpreter should be used to run the file. You can simply ignore it. &lt;/li&gt;
&lt;li&gt;When a user uses the package, they should get an intimation that some process is happening. So to do that add these two &lt;code&gt;console.log()&lt;/code&gt; into the file.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// for user intimation&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="s2"&gt;Building folders and initialising your server...⛳️&lt;/span&gt;&lt;span class="dl"&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="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="s2"&gt;This might take few seconds...⏳&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Now we have to create three folders:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;db &lt;/li&gt;
&lt;li&gt;routes&lt;/li&gt;
&lt;li&gt;models&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In order to do so we will use &lt;code&gt;fs.mkdirSync()&lt;/code&gt;. mkdir means make directory and sync means it will make directory synchronously. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the below code to create folders.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// make folders&lt;/span&gt;
&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mkdirSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cwd&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;/db`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mkdirSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cwd&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;/model`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;mkdirSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cwd&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;/routes`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You might see that I have used &lt;code&gt;process.cwd()&lt;/code&gt;. This means the folders would be created in the current working directory (cwd) in which our package or &lt;code&gt;npx executable&lt;/code&gt; command would be used. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now we have to install some packages so that our server could run. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We will install: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;express&lt;/li&gt;
&lt;li&gt;cors&lt;/li&gt;
&lt;li&gt;jwt&lt;/li&gt;
&lt;li&gt;dotenv&lt;/li&gt;
&lt;li&gt;bcryptjs&lt;/li&gt;
&lt;li&gt;nodemon (dev dependency)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If we want to run commands using a package we would have to use &lt;code&gt;child_process.execSync()&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;child_process&lt;/code&gt; enables us to spawn subprocesses inside the main / parent process. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;execSync&lt;/code&gt; lets us execute shell/terminal commands using nodejs. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the code given below for reference.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;//  install packages&lt;/span&gt;
&lt;span class="nx"&gt;child_process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;npm init -y&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="na"&gt;stdio&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;child_process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;npm install express&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="na"&gt;stdio&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;child_process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;npm install cors&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="na"&gt;stdio&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;child_process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;npm i jsonwebtoken&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="na"&gt;stdio&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;child_process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;npm i dotenv&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="na"&gt;stdio&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;child_process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;npm i bcryptjs&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="na"&gt;stdio&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;child_process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;npm i -D nodemon&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="na"&gt;stdio&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;ul&gt;
&lt;li&gt;Now we have to create a &lt;code&gt;.env&lt;/code&gt; file to store secrets in it. &lt;/li&gt;
&lt;li&gt;To make a file use a method &lt;code&gt;fs.appendFileSync()&lt;/code&gt;. It adds the given data to the file and by any chance if the file is not present then it creates the file and writes the data in it.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cwd&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;/.env`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;`PORT=8080`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Now we have to make the &lt;code&gt;server.js&lt;/code&gt; file and write some boilerplate code in it. &lt;/li&gt;
&lt;li&gt;We will use the same function as above.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cwd&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;/server.js`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;`
const express = require('express');
const app = express();
require('dotenv').config();
const cors = require('cors');

// middlewares
app.use(cors());
app.use(express.json());

// defining port
const PORT = process.env.PORT || 3001;

// setting up an empty GET Route
app.get('/', (req, res)=&amp;gt;{res.json({message: "You've come to the right place... it's a GET request!!"})});

// Starting Server on PORT
app.listen(PORT, () =&amp;gt; console.log('Server started on PORT Number: ' + PORT))
`&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The first argument in &lt;code&gt;fs.appendFileSync()&lt;/code&gt; is the path to the file and the second argument is the data to be written in the file. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If we are going to push the data to a repository we will need a &lt;code&gt;.gitignore&lt;/code&gt; file. So we will create that as well.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cwd&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="s2"&gt;/.gitignore`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="s2"&gt;`
node_modules 
.env
`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Now we will add a final intimation saying that everything is completed and you may use the project now.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&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="s2"&gt;Folders are created and server.js is initialized with boilerplate code...&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt; RUN: nodemon server.js &lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;Happy Coding ✨&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step-4 : Publishing your NPM package
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to the root directory of your project and run the following command.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm publish &lt;span class="nt"&gt;--access&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;public
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;To use the package, run &lt;code&gt;npx @your_username/projectname@latest&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Drum Roll 🥁!!&lt;/p&gt;

&lt;p&gt;You have made your NPM package which handles the boring and tedious task of setting up a backend and you have published it as well. Thank you for reading the blog ✨. &lt;/p&gt;

&lt;p&gt;View full Code:&lt;/p&gt;


&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@shreyazz/backendbuilder?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>npm</category>
      <category>node</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Basics of Typescript</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Tue, 28 Dec 2021 10:28:13 +0000</pubDate>
      <link>https://dev.to/shreyazz/basics-of-typescript-1in1</link>
      <guid>https://dev.to/shreyazz/basics-of-typescript-1in1</guid>
      <description>&lt;p&gt;Hey developers in today's blog we are going to learn about the basics of typescript.&lt;/p&gt;

&lt;p&gt;This is going a be a series of blogs in which I'm gonna help you learn TypeScript in an easy way! &lt;/p&gt;

&lt;p&gt;We are going to cover&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is TypeScript?&lt;/li&gt;
&lt;li&gt;Why should we use it instead of JavaScript?&lt;/li&gt;
&lt;li&gt;Pros and Cons of TypeScript.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;TypeScript is the superset of JavaScript. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;TypeScript can be used to built enterprise level applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;TypeScript provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Static Typing&lt;/li&gt;
&lt;li&gt;Classes&lt;/li&gt;
&lt;li&gt;Interfaces&lt;/li&gt;
&lt;li&gt;Unions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and a ton of amazing things...&lt;/p&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why should you use TS instead of JS?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;TS will save you from more exceptions and project failures.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If we have a function which will add two numbers
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&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;addNums&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&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;a&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;b&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;addNums&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;10&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="c1"&gt;// here the output would be 1010&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As shown in the above example... this code is valid and it will run perfectly but it does not give the expected output. &lt;/p&gt;

&lt;p&gt;These sort of silly failures are prevented by typescript.&lt;/p&gt;

&lt;p&gt;The code in TS would be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;addNums&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kr"&gt;number&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;a&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nx"&gt;b&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="nf"&gt;addNums&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;// output: 20&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="nf"&gt;addNums&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;10&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;// output: this would give an error (argument of type string isn't assignable to string)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If there is a large code-base and there are lots and lots of variables... so it is natural to not remember many of them. TS has a great integration with the IDE and together they make our coding experience a lot more smooth. There are many benefits like :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hover Support&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fcum7oklc9ucjhg8z34wl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fcum7oklc9ucjhg8z34wl.png" alt="hoverIMG" width="449" height="241"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Code auto completion&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With static typed languages the auto complete is better and faster. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Type checking in real time&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In JS we can access the property of an object which does not exists and it will just return &lt;code&gt;undefined&lt;/code&gt; but in TS it will show an error that the property you are trying to access is not present. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Easier Code Factoring&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advantages/Pros of TypeScript
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Steep learning curve&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;You don't have to learn a whole new language as all those features which you are used to  in JS are primarily used in TS also.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Spotting bugs is relatively easy&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;According to a research 15% of bugs are found at the compile stage&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Readability&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;The code becomes more self expressive due to the types.&lt;/li&gt;
&lt;li&gt;The code speaks for itself which helps a lot when working with big teams.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Follows OOP paradigm&lt;/strong&gt; 

&lt;ul&gt;
&lt;li&gt;The concepts of OOPs like classes, inheritance and interfaces can be used in TS.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Huge Community&lt;/strong&gt; 

&lt;ul&gt;
&lt;li&gt;As per reports TS was the second most loved language of 2020.&lt;/li&gt;
&lt;li&gt;There are lots of developers and a great community out there which works on TS and it is also maintained by Microsoft.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantage/Cons of TypeScript
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;TS has to be compiled as the browsers don't understand it.&lt;/li&gt;
&lt;li&gt;Long TS codes might take some time to compile.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was just the basics of typescript and in the next blog I'm gonna explain how to code in typescript (Basic data types, Arrays, Tuples, Union, Interfaces, Types and many more fun stuff!!)&lt;/p&gt;

&lt;p&gt;Thank you so much for reading the whole blog and please share your feedback in the comment section. &lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Make your own API under 30 lines of code</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Fri, 24 Sep 2021 10:31:03 +0000</pubDate>
      <link>https://dev.to/shreyazz/make-your-own-api-under-30-lines-of-code-4doh</link>
      <guid>https://dev.to/shreyazz/make-your-own-api-under-30-lines-of-code-4doh</guid>
      <description>&lt;p&gt;Hey readers 👋🏻, in this blog we are going to discuss about making our own API in just 30 lines of code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Topics Covered :
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;What is an API.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tech used to make one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How to code it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How to deploy it (FOR FREE).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Those who all know what APIs are and don't want to know anything else then 'How to code it', you can skip to that part directly.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  What is an API :
&lt;/h3&gt;

&lt;p&gt;API stands for &lt;strong&gt;Application Programming Interface&lt;/strong&gt;, which is a way for computer to talk to each other. APIs are just like website, except the UI part, it sends a &lt;strong&gt;request&lt;/strong&gt; to a server and in return the server send a &lt;strong&gt;response&lt;/strong&gt; . &lt;/p&gt;

&lt;p&gt;Most APIs which we use are &lt;strong&gt;RESTFUL APIs&lt;/strong&gt;, which means they follow a set of protocols/rules .&lt;/p&gt;

&lt;p&gt;You all already know what URLs are, but APIs use &lt;strong&gt;URIs&lt;/strong&gt; which stands for &lt;strong&gt;Uniform Resource Identifiers&lt;/strong&gt; and they help to differentiate between data on a server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fhk7ihl7yd6zormxja38h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fhk7ihl7yd6zormxja38h.png" alt="api" width="462" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There can me many more end points, like here in the above image the end point is &lt;code&gt;/names&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;There are many requests we can make to the server but most common ones are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GET: Reading the data.&lt;/li&gt;
&lt;li&gt;POST: Creating new data.&lt;/li&gt;
&lt;li&gt;PATCH: Updating new data.&lt;/li&gt;
&lt;li&gt;DELETE: Delete new data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We have talked a lot about requesting, let's talk about responses.&lt;/p&gt;

&lt;p&gt;There is a thing called status code, which tells you about the response you got from the server. The responses can be divided into 3 levels.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2** Level (200-300) : Everything was fine, the response is fetched.&lt;/li&gt;
&lt;li&gt;4** Level (400-500): There was something with our request, and the data is not fetched.&lt;/li&gt;
&lt;li&gt;5** Level (500+):  Server has failed to send the data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tech used to make an API:
&lt;/h3&gt;

&lt;p&gt;I have used :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;li&gt;Node.JS

&lt;ul&gt;
&lt;li&gt;Express JS&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Replit (for deployment)&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  How to code an API:
&lt;/h3&gt;

&lt;p&gt;This is going to be the most important part of the blog.&lt;/p&gt;

&lt;p&gt;In this blog, I am going to make an API which returns the details of devices available at an electronic shop.&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;products&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iPhone 13&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;White&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Apple&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;OnePlus 9&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Blue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Oneplus&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iPhone 12&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Purple&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Apple&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above is an object which we want the API to return.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By this point I am assuming that you all have initialized npm and installed express &lt;/p&gt;

&lt;p&gt;npm init -y (Initializes NPM)&lt;/p&gt;

&lt;p&gt;npm i express (Install Express)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Steps :
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Step 1: We have to import express in our project.

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;const express = require('express');&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Step 2 : Initialize a variable to call the main &lt;code&gt;express()&lt;/code&gt; method.

&lt;ul&gt;
&lt;li&gt; &lt;code&gt;const app = express();&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Step 3: Setup a port.

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;const PORT = 8080;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Step 4: Use a &lt;a href="https://en.wikipedia.org/wiki/Middleware" rel="noopener noreferrer"&gt;middleware&lt;/a&gt; to parse the data into json.

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;app.use(express.json());&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Step 5: Add the Product Object to the file.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Till now the code looks like :&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;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&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;PORT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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;products&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iPhone 13&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;White&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Apple&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;OnePlus 9&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Blue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Oneplus&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iPhone 12&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Purple&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Apple&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Step 6: Make the server listen to our port / Start the server.

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;app.listen(PORT, () =&amp;gt; console.log('server is 🟢'))&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.listen()&lt;/code&gt; is a function, which starts the server and listens at the port assigned.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;The code is 👇🏻&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;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&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;PORT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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;products&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iPhone 13&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;White&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Apple&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;OnePlus 9&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Blue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Oneplus&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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;iPhone 12&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Purple&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Apple&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PORT&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;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="s2"&gt;`API 🟢`&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Step 7: Make a function which handles &lt;code&gt;GET&lt;/code&gt; Requests.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For this we have an in-built function called as &lt;code&gt;.get(resource-link, callBack-Function)&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/products&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&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="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;products&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;ul&gt;
&lt;li&gt;
&lt;p&gt;Here we are setting the resource-link as &lt;code&gt;/products&lt;/code&gt; which means the user can get the data when he heads to &lt;code&gt;www.xyz.com/products&lt;/code&gt;. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the callback function, we have 2 parameters one is for request and another is for response. &lt;/li&gt;
&lt;li&gt;Now as a server, when a user sends get request we have to respond to that and send data.&lt;/li&gt;
&lt;li&gt;In agreement to the above point, we are sending the data using &lt;code&gt;res&lt;/code&gt;  (response parameter).&lt;/li&gt;
&lt;li&gt;To send the data we use &lt;code&gt;.send()&lt;/code&gt; method, and additionally we are also sending the &lt;code&gt;status code&lt;/code&gt; using &lt;code&gt;.status()&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;That's It!! Your API is ready 🎉&lt;/strong&gt; and right now you can start your &lt;code&gt;localhost&lt;/code&gt; server and head on to &lt;code&gt;http://localhost:3000/products&lt;/code&gt; and you will be able to see the data.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to deploy your API for FREE :
&lt;/h3&gt;

&lt;p&gt;If we do not deploy our API, then what is the use of it?&lt;/p&gt;

&lt;p&gt;Deployment in simple terms is making your API go live for 24 x 7, you can use it whenever you like.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By this point I am assuming that you all have a Replit Account &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The steps are really simple :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 1: Make a new project in replit account under the section of Node.JS&lt;/li&gt;
&lt;li&gt;Copy Paste the code you just wrote in your text editor / IDE.&lt;/li&gt;
&lt;li&gt;On the right hand side, you'll see a package section.

&lt;ul&gt;
&lt;li&gt;Go inside it and download express.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Run the code.&lt;/li&gt;

&lt;li&gt;You'll see a URI on the right hand side of the screen like this 👇🏻&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fc26ht9dpznkwx8dx7wwm.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fc26ht9dpznkwx8dx7wwm.PNG" alt="link" width="788" height="893"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now head on to the link and write &lt;code&gt;/products&lt;/code&gt; or the any endpoint which you created and you'll be able to see the data in json format.&lt;/p&gt;




&lt;p&gt;Thank you so much for reading the whole blog 👏🏻, I really appreciate it.&lt;/p&gt;

&lt;p&gt;Till then...good bye !&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>webdev</category>
    </item>
    <item>
      <title>JavaScript Objects</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Sat, 18 Sep 2021 10:25:32 +0000</pubDate>
      <link>https://dev.to/shreyazz/javascript-objects-57ob</link>
      <guid>https://dev.to/shreyazz/javascript-objects-57ob</guid>
      <description>&lt;p&gt;Hey developers 👋🏻, in this blog we will be discussing about JavaScript Objects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Topics Covered :
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;What are JavaScript Objects.&lt;/li&gt;
&lt;li&gt;Why to use them?&lt;/li&gt;
&lt;li&gt;Three ways to create them.&lt;/li&gt;
&lt;li&gt;How to access properties from Objects.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What are JavaScript Objects ?
&lt;/h3&gt;

&lt;p&gt;JavaScript Objects are just as real world objects, for example:&lt;/p&gt;

&lt;p&gt;A car is an object which has some property :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;One Engine&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;4 Tiers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;4 Doors&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Company's Name&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Color&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and many more. We just have to express this in a syntactical way :&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;let&lt;/span&gt; &lt;span class="nx"&gt;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Tesla&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Matte-Black&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;tiers&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="na"&gt;doors&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="na"&gt;engine&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here as we can see there are 4 properties company, color, tiers and doors, where all of these properties are defined in a &lt;code&gt;key : value&lt;/code&gt; pair and the key is the indicator of the value.&lt;/p&gt;

&lt;p&gt;So if I &lt;code&gt;console.log(car)&lt;/code&gt; I would get :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fs381hi8tucy859vpdhrg.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fs381hi8tucy859vpdhrg.PNG" alt="output" width="220" height="119"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;further in this blog, I will explain how to make an object in detail but before understanding that let's understand the need of objects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why to use Objects ?
&lt;/h3&gt;

&lt;p&gt;Objects are non-primitive data types which means they are not meant to store a single data, rather it is meant to store more complex entities. We can store multiple data-types inside an object, even functions are accepted in them.&lt;/p&gt;

&lt;p&gt;In a very layman's terms, objects is a mini version of class, which can be used to store multiple entities and can be used in multiple places though it would be wrong to compare objects and classes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Three Ways to Create Objects :
&lt;/h3&gt;

&lt;p&gt;Three ways to create objects are :&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Object Literals :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;i.&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Shreyas Pahune&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;isMale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;favLangs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
              &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;JavaScript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TypeScript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Java&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Dart/Flutter&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ii. Here in the above way, we just have to insert the &lt;code&gt;key : value&lt;/code&gt; pair inside a pair of curly brackets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. &lt;code&gt;New&lt;/code&gt; Keyword :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;i.&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
      &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Shreyas Pahune&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
      &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;
      &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isMale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;favLangs&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;JavaScript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;TypeScript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Java&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Dart/Flutter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;ii. When using this way, the code gets unnecessarily long, while you can achieve the same result by using the Object Literal method (1st method).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Using &lt;code&gt;Object.create() :&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;i.&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;full-name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;age&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="na"&gt;isMale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="na"&gt;favLangs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
              &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Lang1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Lang2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Lang3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Lang4&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;const&lt;/span&gt; &lt;span class="nx"&gt;shreyas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nx"&gt;shreyas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Shreyas&lt;/span&gt; &lt;span class="nx"&gt;Pahune&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;
      shreyas.age = 18
      shreyas.isMale = true
      shreyas.favLangs :  [&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;JavaScript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;, &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;TypeScript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;, &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;Java&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;, &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="nx"&gt;Dart&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;Flutter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;]

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

&lt;/div&gt;



&lt;p&gt;ii. &lt;code&gt;Object.create()&lt;/code&gt; always makes an new object whilst keeping the original object as an template to follow.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Retrieve Data from Objects ?
&lt;/h3&gt;

&lt;p&gt;There are two ways of retrieving data from an object :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dot Notation&lt;/li&gt;
&lt;li&gt;Bracket Notation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Dot Notation is :&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;let&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Shreyas Pahune&lt;/span&gt;&lt;span class="dl"&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// expected output : Shreyas Pahune&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Bracket Notation is :&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;let&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Shreyas Pahune&lt;/span&gt;&lt;span class="dl"&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;// expected output : Shreyas Pahune&lt;/span&gt;

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

&lt;/div&gt;






&lt;h3&gt;
  
  
  Bonus 🎈 :
&lt;/h3&gt;

&lt;p&gt;There is a thing called object constructor where we use a special type of function to create an object.&lt;/p&gt;

&lt;p&gt;The special function is known as constructor function and it is somewhat like &lt;code&gt;Object.create()&lt;/code&gt; but better.&lt;/p&gt;

&lt;p&gt;Here in this function, we have to pass parameters and it is suggested to use this or the object literal type to create small-medium sized objects.&lt;/p&gt;

&lt;p&gt;Here is the syntax for it 👇🏻&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;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isMale&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;favLang&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&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;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;age&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;isMale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;isMale&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;favLang&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;favLang&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;displayInfo&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;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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="s2"&gt;`My name is &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;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, I am &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;age&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; years old and I like to code in 
      &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;favLang&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;personOne&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Shreyas&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Typescript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;JavaScript&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Java&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Dart/Flutter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="nx"&gt;personOne&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;displayInfo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Here in the above example, we have made a function called person &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE: The first letter of a constructor function is to be kept capital. Nothing compulsory but just a convention!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The function takes 4 parameters/arguments, and the &lt;code&gt;this&lt;/code&gt; keyword refers to the object it indicates, so here if I make another person named as personTwo and give them a name as Anushka then the object will use the new name instead of the old name passed in. &lt;/p&gt;

&lt;p&gt;Here we have made a function which is defined as a property and after making an instance(personOne) of the Person Object we can call the function as usual.&lt;/p&gt;

&lt;p&gt;Expected output of the function would be :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;My name is Shreyas, I am 18 years old and I like to code in Typescript,JavaScript,Java,Dart/Flutter!&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;Thank you so much for reading the whole blog 👏🏻, I really appreciate it.   &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;PS :  I am publishing a new blog after a very long time so I'll try to be more regular xD! Till then... bye bye 👋🏻.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Regex 101</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Wed, 21 Jul 2021 18:01:56 +0000</pubDate>
      <link>https://dev.to/shreyazz/regex-101-2m7m</link>
      <guid>https://dev.to/shreyazz/regex-101-2m7m</guid>
      <description>&lt;p&gt;Hey readers 👋🏻, in this blog we are going to talk about &lt;code&gt;Regular Expressions&lt;/code&gt; or we can also call it &lt;code&gt;REGEX&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;&lt;code&gt;REGEX&lt;/code&gt; is sequence of characters which are in a certain patter, and these patterns help us &lt;code&gt;find&lt;/code&gt; or &lt;code&gt;find and replace&lt;/code&gt; or &lt;code&gt;validate&lt;/code&gt; things like  &lt;code&gt;email, passwords and usernames&lt;/code&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Let's start learning 🐱‍🏍:
&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Basics :&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The most easy way to explain &lt;code&gt;regex&lt;/code&gt; with an example is if:&lt;/p&gt;

&lt;p&gt;we want to search the word &lt;code&gt;JavaScript&lt;/code&gt; in a string.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ftm1pbxe8mptm9v1uj2z5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ftm1pbxe8mptm9v1uj2z5.png" alt="first" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now this example is very basic but believe me &lt;code&gt;REGEX&lt;/code&gt; has lots and lots of use-cases.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Multiple Possible Characters :&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Let's see an example where you want to see if the string contains many possibilities for example if you want to search for &lt;code&gt;dog&lt;/code&gt; or &lt;code&gt;cat&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;We can do this by using  &lt;code&gt;|&lt;/code&gt; the &lt;code&gt;OR&lt;/code&gt; sign.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fxdqipdsne87yr860ejim.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fxdqipdsne87yr860ejim.png" alt="second" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here if the &lt;code&gt;petString&lt;/code&gt; would contain &lt;code&gt;Shreyas loves JavaScript&lt;/code&gt; then the output would have been &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To be clear, the REGEX patterns are case sensitive, so if a string would contain &lt;code&gt;shreyas&lt;/code&gt; and I search for &lt;code&gt;ShreyaS&lt;/code&gt; then the output would be &lt;code&gt;false&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Case Sensitiveness :&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;What should we do when we are not sure about the case... No worries! We can make our REGEX Pattern ignore the case.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fc93agu0yjurjyxupkafn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fc93agu0yjurjyxupkafn.png" alt="three" width="800" height="379"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see we have used &lt;code&gt;i&lt;/code&gt; in &lt;code&gt;regex1&lt;/code&gt;, and there are many such flags which gives us a lot of control over the pattern.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;i&lt;/code&gt; stands for &lt;code&gt;irrespective of the case&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here we are using &lt;code&gt;.test()&lt;/code&gt; method, which is an inbuilt method in JavaScript, which returns true or false according to the pattern entered.&lt;/p&gt;

&lt;p&gt;The Syntax is &lt;code&gt;pattern.test(String-which-has-to-be-tested)&lt;/code&gt; . &lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Global Searching :&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;.test()&lt;/code&gt; has a draw back, which is that it only returns true or false, and if true it does not tell us how many times the pattern was matched, so to back this drawback, JS has another inbuilt method called as &lt;code&gt;.match()&lt;/code&gt; which let's us know how many times the pattern is matched in the string.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.match()&lt;/code&gt; return an array of results which have successfully matched the pattern, and the array's length is the time the pattern was recognized.&lt;/p&gt;

&lt;p&gt;Let me show an example 👇🏻:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F1j1ti5rxlxxjh458ylaj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F1j1ti5rxlxxjh458ylaj.png" alt="four" width="800" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here you can see the syntax of &lt;code&gt;.match()&lt;/code&gt; is a little bit different when compared to &lt;code&gt;.test()&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;code&gt;.match()&lt;/code&gt; 's syntax is :  &lt;code&gt;string.match(regex-pattern);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Also you can see that I have used another flag, which is &lt;code&gt;g&lt;/code&gt; and it stands for &lt;code&gt;global&lt;/code&gt;, which helps us find the perfect match globally in the string.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Find Group of Letters :&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We can group many letters together to find them inside a string. REGEX gives us flexibility with &lt;code&gt;Character Classes&lt;/code&gt;, these allow us to define a group of characters and they have to be enclosed in &lt;code&gt;[  ]&lt;/code&gt; (Square Brackets) .&lt;/p&gt;

&lt;p&gt;It will be more clear when you see an example.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;We have to find every vowel inside a string.&lt;/code&gt; 👇🏻&lt;br&gt;
&lt;a href="https://media2.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%2F4rxcqgdgavjuu5cgqjr1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F4rxcqgdgavjuu5cgqjr1.png" alt="five" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The pattern has 2 flags, which are non case sensitive and to check globally in the string. &lt;/p&gt;

&lt;p&gt;Here &lt;code&gt;[aeiou]&lt;/code&gt; vowels are grouped together and are individually searched in the string.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Match anything using Wildcard  period / dot :&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Some times we just have to search for words which end with some certain letters or which start from some certain letters. To do so, we have wildcard period which is basically a &lt;code&gt;.&lt;/code&gt; period/dot. &lt;/p&gt;

&lt;p&gt;If we have to match words which end with the letters &lt;code&gt;un&lt;/code&gt; . For example &lt;code&gt;fun&lt;/code&gt; or &lt;code&gt;run&lt;/code&gt; or &lt;code&gt;sun&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;For that we have 👇🏻&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ftfb5az0vfcc9u2z1ygkk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ftfb5az0vfcc9u2z1ygkk.png" alt="six" width="800" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This pattern will check for any word ending with un and it will do it irrespective of the case(&lt;code&gt;i&lt;/code&gt; flag) and would search in the whole string (&lt;code&gt;g&lt;/code&gt; flag).&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Range of Characters :&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We can also provide a range of characters to check from.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F7cuap54wk9u9bf1jasg9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F7cuap54wk9u9bf1jasg9.png" alt="seven" width="800" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For Example: If you are sure that there are possibilities that the word may start with any character but the ending will be with the letters &lt;code&gt;at&lt;/code&gt; , then we can give a range of characters which will check the string and if matched then return an array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;If no value is found, NULL would be returned!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Match Numbers :&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;What if, you wanna match numbers?? Don't worry REGEX has got you covered!&lt;/p&gt;

&lt;p&gt;Just like characters we can write &lt;code&gt;/[0-9]/g&lt;/code&gt;, that's it, all the numbers are covered.&lt;/p&gt;

&lt;p&gt;But as we all know, us developers...we are lazy 💤! So why to write &lt;code&gt;/[0-9]/&lt;/code&gt; when you can also write &lt;code&gt;/[\d]/g&lt;/code&gt; and this &lt;code&gt;d&lt;/code&gt; stands for digits!&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Match Number and Characters :&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To match number and characters, we can write 👇🏻&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F69f62zyfg14i9chdwnyy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F69f62zyfg14i9chdwnyy.png" alt="eight" width="800" height="242"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But isn't this REGEX Pattern too long?? We have a shorthand for this, which is &lt;code&gt;/\w/g&lt;/code&gt; and instead of the whole REGEX pattern you can just write the shorthand.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Check for Minimum and Maximum Characters   :&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;We  can set a min and a max amount of characters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fza8lmn75jgca1evfa5qx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fza8lmn75jgca1evfa5qx.png" alt="nine" width="800" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This REGEX pattern allows only those strings which have equal or greater length then 5 and are under or equal to 10.&lt;/p&gt;

&lt;p&gt;The syntax for that is &lt;code&gt;/[regex here]{min-number, max-number}/g&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Challenge 🎯:
&lt;/h2&gt;

&lt;p&gt;I wanna give a quick challenge to all the readers, why don't you make a REGEX which verifies usernames, and the conditions are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Username should have numbers.&lt;/li&gt;
&lt;li&gt;Username can have an underscore.&lt;/li&gt;
&lt;li&gt;Username should not have any special characters. &lt;/li&gt;
&lt;li&gt;Username should have minimum 5 characters and maximum 15 characters. &lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;Thank you so much for reading the whole blog 🎉, if you liked it do share it with your friends and implement REGEX in your upcoming projects! It has saved me from writing lots of line of code and a lot of time too, I am sure it will be very effective for you too!&lt;/p&gt;

&lt;p&gt;Till the next blog... Goodbye 👋🏻 !!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>codequality</category>
    </item>
    <item>
      <title>Free hosting using Heroku</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Wed, 14 Jul 2021 19:21:00 +0000</pubDate>
      <link>https://dev.to/shreyazz/free-hosting-using-heroku-1g39</link>
      <guid>https://dev.to/shreyazz/free-hosting-using-heroku-1g39</guid>
      <description>&lt;p&gt;Hey readers 👋🏻,&lt;br&gt;
I hope you all are doing fine, in this blog we are going to discuss about hosting and how to host our own discord bot, which we made in my &lt;a href="https://dev.to/shreyazz/make-a-discord-bot-in-just-30-lines-of-code-44el"&gt;previous blog&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;We are going to use &lt;strong&gt;Heroku&lt;/strong&gt; to host our bot. &lt;/p&gt;

&lt;h3&gt;
  
  
  What do I mean when I say 'HOST' a discord bot?
&lt;/h3&gt;

&lt;p&gt;So basically you cant run the program which you made for 24x7 and 365 days, so we need a server to do that.&lt;/p&gt;

&lt;p&gt;The hosting platform has a lot of servers which will serve our discord bot for 24x7 and 365 days, so you and your friends can anytime use it anytime!!&lt;/p&gt;

&lt;h4&gt;
  
  
  Let's host it now 🤖 :
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sign-up or Log-in to Heroku :&lt;/strong&gt;

&lt;ol&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Fuyql0ssmkmuo0210ii1u.PNG" alt="login" width="800" height="407"&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Create a new app :&lt;/strong&gt;

&lt;ol&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Fnrt9su6x0viar8zlndnh.PNG" alt="second" width="800" height="408"&gt;&lt;/li&gt;
&lt;li&gt;Click on the new button on the &lt;code&gt;top-right corner&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click on Create New App&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Name your project and select a region:&lt;/strong&gt;

&lt;ol&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Fefxt00tk9z7rqr2dsstt.PNG" alt="third" width="800" height="408"&gt;&lt;/li&gt;
&lt;li&gt;Click on Create App&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Now you have to push the source code on GitHub repo.

&lt;ol&gt;
&lt;li&gt;Make sure source code does not contain your discord bot TOKEN or any other API key.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Now you will have this screen:

&lt;ol&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Fteajlym42ngt3g66uv01.PNG" alt="connect" width="800" height="406"&gt;&lt;/li&gt;
&lt;li&gt;Click on the &lt;code&gt;Connect to GitHub&lt;/code&gt; button.&lt;/li&gt;
&lt;li&gt;Then select the repository which you created.&lt;/li&gt;
&lt;li&gt;Once the repo is connected, just press on &lt;code&gt;Enable Automatic Deploys&lt;/code&gt;, which will help us to deploy the new version of our bot automatically whenever the repo is updated.&lt;/li&gt;
&lt;li&gt; Refer to this image 👇🏻&lt;img src="https://media2.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%2Fbo686ov9x1m7a56fe1gd.PNG" alt="six" width="800" height="407"&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Then go the settings tab:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on &lt;code&gt;Reveal Config Vars&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;👇🏻 &lt;img src="https://media2.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%2Fvzmhw8inm98fo6v56o1o.PNG" alt="seven" width="800" height="407"&gt;
&lt;/li&gt;
&lt;li&gt;Inside the config vars enter your key and value pair of your API KEY and Discord Bot's Token. 👇🏻 &lt;/li&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Fczzp1vx5rznfizn5x80g.PNG" alt="eight" width="800" height="407"&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Add a BuildPack:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;BuildPack are scripts that are run when your bot will be deployed. They are used to install dependencies for your bot and configure your environment.&lt;/li&gt;
&lt;li&gt;Click on  add BuildPack 👇🏻 &lt;img src="https://media2.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%2Fdnwltj1yy5h4wfiaiblb.PNG" alt="buildpack" width="800" height="407"&gt;
&lt;/li&gt;
&lt;li&gt;Then click on Node.JS 👇🏻 as our bot is made using JS and Node Modules. &lt;/li&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Fqwn3j784kudilbrwvo8e.PNG" alt="add" width="800" height="407"&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;After these steps, go to the home directory of your project and make a new File with the name of &lt;code&gt;Procfile&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;Procfile&lt;/code&gt; should contain &lt;code&gt;worker node &amp;lt;Source-folder-Name&amp;gt;/&amp;lt;file-which-has-bot's-code&amp;gt;&lt;/code&gt; in this case, it will be &lt;code&gt;worker node src/bot.js&lt;/code&gt;  .&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Procfile&lt;/code&gt; will help the Heroku's server to run our bot.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Now push the new change to the repository.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Go to the deploy tab:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now click on the &lt;code&gt;Deploy Branch&lt;/code&gt; button.&lt;/li&gt;
&lt;li&gt;You will see a green check mark which will ensure you that there are no errors while deploying 👇🏻.&lt;/li&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Fz5i73dwjv7fe8ac8f809.PNG" alt="check" width="800" height="378"&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Go to the resource tab:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Refresh the page once.&lt;/li&gt;
&lt;li&gt;You can see 2 Dynos 👇🏻&lt;/li&gt;
&lt;li&gt;
&lt;img src="https://media2.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%2F03ld4n7s45gnk8w8m26l.PNG" alt="dyno" width="800" height="407"&gt;
Click on the pen icon and switch off the &lt;code&gt;Web&lt;/code&gt; and Switch on the &lt;code&gt;Worker&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;Click on more and then click on view logs.&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;That's it you have successfully hosted your discord bot, and now you and your friends can use the bot anytime you want 🎉!!&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;

&lt;/ol&gt;




&lt;p&gt;Thank you so much for reading the whole blog and if you liked it, do share it with your developer friends 💻!!&lt;/p&gt;




&lt;p&gt;In case you want to learn how to make a discord bot(my previous bog's topic)and how to host it on Heroku, do check out my talk 🎉!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=FAbGyOPxw-U" rel="noopener noreferrer"&gt;Make a Discord Bot using Discord.js and host it online on Heroku&lt;/a&gt;&lt;/p&gt;

</description>
      <category>heroku</category>
      <category>watercooler</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Make a Discord bot in just 30 lines of code.</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Sun, 11 Jul 2021 18:02:51 +0000</pubDate>
      <link>https://dev.to/shreyazz/make-a-discord-bot-in-just-30-lines-of-code-44el</link>
      <guid>https://dev.to/shreyazz/make-a-discord-bot-in-just-30-lines-of-code-44el</guid>
      <description>&lt;p&gt;Hey everyone 👋🏻, today we are going to make a discord bot 🤖 which will send gifs according to the user &lt;strong&gt;in just 30 lines of code!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The way this bot will work is, if you write &lt;code&gt;.gif happy&lt;/code&gt; then the bot will send a random happy gif.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are we going to use to build this mini-project:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;li&gt;NPM Packages:

&lt;ul&gt;
&lt;li&gt;Discord.js&lt;/li&gt;
&lt;li&gt;DOTENV&lt;/li&gt;
&lt;li&gt;node-fetch&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Okay so let's get started 🎉!!&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps :
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;We have to go to the &lt;a href="https://discord.com/developers/applications" rel="noopener noreferrer"&gt;discord developer portal&lt;/a&gt; and create a new application.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fd7zg9nzgm77funm73znr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fd7zg9nzgm77funm73znr.png" alt="portal" width="800" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Then you have to create a new application ☝🏻. &lt;code&gt;(the blue button on top-right corner)&lt;/code&gt; .&lt;/li&gt;
&lt;li&gt;Give a name to your application.&lt;/li&gt;
&lt;li&gt;Then on the left hand side, click on bot👇🏻 .&lt;/li&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Ferzhg0zi8ykpiewhbd5g.PNG" alt="second" width="800" height="408"&gt;&lt;/li&gt;
&lt;li&gt;After clicking on bot, now click on &lt;code&gt;Add Bot&lt;/code&gt; on the right hand side, and after this step you will have a screen like this 👇🏻.&lt;/li&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Fw1ryr6lckw6gvtg7kqny.PNG" alt="third" width="800" height="407"&gt;&lt;/li&gt;
&lt;li&gt;Now the Token is something which you have to keep a secret and not reveal anywhere or to anyone.&lt;/li&gt;
&lt;li&gt;If you reveal it by mistake, no worries just regenerate it, but make sure you don't or else someone can take over your bot.&lt;/li&gt;
&lt;li&gt;Now we have to decide what permissions does our bot need, and after deciding this, just head to OAuth2 section on the right hand side of your screen.&lt;/li&gt;
&lt;li&gt;You will have a screen when many check boxes, and you have to click on the checkbox which says &lt;code&gt;bot&lt;/code&gt; 👇🏻.&lt;/li&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Flijrp59d102ui3r06idc.PNG" alt="four" width="800" height="408"&gt;&lt;/li&gt;
&lt;li&gt;Then click on the permission you have to give to the bot.&lt;/li&gt;
&lt;li&gt;After that click on the link and copy it, after that paste it into a new tab and authorize it to add it to a new server.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now we just have to code it!&lt;/p&gt;

&lt;p&gt;Before explaining the code, let me explain you the folder structure 👇🏻. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fq82kix2zwih2msu2qp5w.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fq82kix2zwih2msu2qp5w.PNG" alt="folder" width="177" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;There is a folder called &lt;code&gt;src&lt;/code&gt; in which we have a main file called &lt;code&gt;bot.js&lt;/code&gt; in which we are going to code our bot.&lt;/li&gt;
&lt;li&gt;Okay so you can see that there are two files and a folder, named as &lt;code&gt;package-lock.json&lt;/code&gt;, &lt;code&gt;package.json&lt;/code&gt; and &lt;code&gt;node_modules&lt;/code&gt; respectively, they are basically of node packages and their information.&lt;/li&gt;
&lt;li&gt;There is also a &lt;code&gt;.env&lt;/code&gt; file but we will discuss about it later in this blog.&lt;/li&gt;
&lt;li&gt;Okay so we have to use 3 packages to make a discord bot, they are as follows:

&lt;ol&gt;
&lt;li&gt;discord.js (&lt;code&gt;npm i discord.js&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;dotenv (&lt;code&gt;npm i dotenv&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;node-fetch (&lt;code&gt;npm i node-fetch&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Now using this image as my reference, I am going to explain the code.&lt;/li&gt;

&lt;li&gt;&lt;img src="https://media2.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%2F4t8atty7rujrytdy4wyv.png" alt="code" width="800" height="798"&gt;&lt;/li&gt;

&lt;/ol&gt;

&lt;p&gt;As you can see ☝🏻, there are only 30 lines of code! How amazing it that?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your own discord bot 🤖 in just 30 lines of code!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Okay so the first and the third line of code are the import  statements which can also be written as :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;import discord from 'discord.js;'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The second line of code is basically us initializing the client/user, which in this case will be our bot and the users themselves .&lt;/p&gt;

&lt;p&gt;and the fourth line is importing the env package and configuring it, so basically &lt;code&gt;.env&lt;/code&gt; &lt;strong&gt;files stores all your secrets, like your discord bot's token or your API Key, these things will not be uploaded on GitHub using the git ignore file.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Okay so in JavaScript there is this thing called &lt;code&gt;addEventListner&lt;/code&gt; which helps us to react to certain events, like if a user clicks on something or double-tap on something a particular function should run.&lt;/p&gt;

&lt;p&gt;In the same way here in discord.js &lt;code&gt;addEventListner&lt;/code&gt; is more or less replaced by &lt;code&gt;.on&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;All of the &lt;code&gt;.on&lt;/code&gt; functions are called in regards to the &lt;code&gt;client&lt;/code&gt; so we have to write &lt;code&gt;client.on('event', callBackFunction)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;On line number 6 you can see that I have written a function which is &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F1fi5gxnbad65u50jv6jw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F1fi5gxnbad65u50jv6jw.png" alt="ready" width="800" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This basically means that, whenever the user is ready and logged in the console should log &lt;code&gt;&amp;lt;Name of the Bot&amp;gt; is up and ready!&lt;/code&gt; and name of the bot is fetched by this inbuilt property known as &lt;code&gt;.user.tag&lt;/code&gt; , which is to be called in regards to the &lt;code&gt;client&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;Now we have to make our bot login to the server. And  for that we have another inbuilt method/function called &lt;code&gt;.login&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;So we can write : &lt;code&gt;client.login(process.env.TOKEN)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now you might wonder what is this &lt;code&gt;process.env.TOKEN&lt;/code&gt;, this is the way we call variables from our &lt;code&gt;.env&lt;/code&gt; file.&lt;br&gt;
So let me show what is stored inside &lt;code&gt;.env&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fo99m5yd2vqufzw18wcfq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fo99m5yd2vqufzw18wcfq.png" alt="env" width="800" height="784"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here in this file, we have to put our bot token inside a pair of single or double quotes and our tenor API key (you can generate it from &lt;a href="https://tenor.com/developer/keyregistration" rel="noopener noreferrer"&gt;here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;For example if you want to call the &lt;code&gt;tenor api key&lt;/code&gt; inside your &lt;code&gt;bot.js&lt;/code&gt; file, you just have to write &lt;code&gt;process.env.TENOR&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And you can make a &lt;code&gt;try-catch&lt;/code&gt; block around the &lt;code&gt;client.login()&lt;/code&gt; function, so if any error occurs, we can catch it and show it on the console. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F6623bj3fmz7ukbj1wxpy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F6623bj3fmz7ukbj1wxpy.png" alt="try-catch" width="800" height="543"&gt;&lt;/a&gt;&lt;br&gt;
So as of now, we have our boiler plate code ready with us, which is 👇🏻: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Famssijt8pdyuvc2ttm3h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Famssijt8pdyuvc2ttm3h.png" alt="boiler" width="800" height="623"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's code the main functionality of the bot now.&lt;/p&gt;

&lt;p&gt;Now all the code discussed below will be in the reference to 👇🏻 this image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fvof6263rdads9k8nj6n4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fvof6263rdads9k8nj6n4.png" alt="main" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's understand the above code step-by-step:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Creating an add event listener to react when the user sends message:

&lt;ol&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Ffrfzpeoygaulx3ewj3xt.png" alt="addEve" width="800" height="498"&gt;&lt;/li&gt;
&lt;li&gt;Here the parameter &lt;code&gt;msg&lt;/code&gt; will contain the message which user has sent. &lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Let's add a prefix to our bot, so it will only react if we write &lt;code&gt;.gif&lt;/code&gt;.

&lt;ol&gt;
&lt;li&gt;Just to be a little safe, I am going to write the main functionality inside a &lt;code&gt;try-catch&lt;/code&gt; block.&lt;/li&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Fxybcvar7n5fyqxyl3ing.png" alt="try" width="800" height="635"&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;msg.content&lt;/code&gt; helps us to fetch the content inside the msg. In leman's term, it is like &lt;code&gt;.innerText&lt;/code&gt; in JavaScript. &lt;/li&gt;
&lt;li&gt;Here when the user will write &lt;code&gt;.gif&lt;/code&gt; the code inside the &lt;code&gt;if&lt;/code&gt; statement will be executed.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Now let's get user's queries.

&lt;ol&gt;
&lt;li&gt;Now if a user writes &lt;code&gt;.gif batman&lt;/code&gt; then this will be considered as a string and a problem arises here, which is how do we separate the bot command and the user's query.&lt;/li&gt;
&lt;li&gt;We do that by an inbuilt function called &lt;code&gt;.split()&lt;/code&gt;, which will help us to separate the whole string into two different values stored in an array, for example: if I write &lt;code&gt;.gif batman&lt;/code&gt; then &lt;code&gt;.split()&lt;/code&gt;  will make an array :  &lt;code&gt;['.gif', 'batman']&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Let's see it's code.&lt;/li&gt;
&lt;li&gt;&lt;img src="https://media2.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%2F0hgyddtr6tzi94rcecmy.png" alt="split" width="800" height="667"&gt;&lt;/li&gt;
&lt;li&gt;We are going to compare the &lt;code&gt;first index of query&lt;/code&gt; which will be &lt;code&gt;.gif&lt;/code&gt;  to the string .gif.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Let's discuss about the API and Fetching it.

&lt;ol&gt;
&lt;li&gt;I am using node-fetch to fetch the API.&lt;/li&gt;
&lt;li&gt;The base of the API is

&lt;ol&gt;
&lt;li&gt; &lt;code&gt;https://g.tenor.com/v1/search?q=USERQUERY&amp;amp;key=API-KEY&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;And in order to take query from the user and give the key as your API Key we have to make this URL dynamic.&lt;/li&gt;

&lt;li&gt;We can do that by using template literals.

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;https://g.tenor.com/v1/search?q=${query[1]}&amp;amp;key=${process.env.TENOR}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;And now the  code looks like this.&lt;/li&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Fnl5eu92onady5c3o02my.png" alt="url" width="800" height="630"&gt;&lt;/li&gt;
&lt;li&gt;And the query has to be the second value (First Index) in the array.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Let's fetch the API now.

&lt;ol&gt;
&lt;li&gt;We just have to put &lt;code&gt;async&lt;/code&gt; in front of the callback function as you can see in the above image on line number 10.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;async&lt;/code&gt; will make your function, asynchronous and then we will use &lt;code&gt;await&lt;/code&gt; to wait for the response from the API.&lt;/li&gt;
&lt;li&gt;&lt;img src="https://media2.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%2Facmflsactcaxk46j97fb.png" alt="without" width="800" height="664"&gt;&lt;/li&gt;
&lt;li&gt;Now here we will have a problem, which is we will only receive one GIF every time.&lt;/li&gt;
&lt;li&gt;Now the API will return 20 GIFs and we have to pick a random one (on line 17).&lt;/li&gt;
&lt;li&gt;So to do this, we will make a random variable which will choose one GIF.&lt;/li&gt;
&lt;li&gt;Now the final code looks like 👇🏻
&lt;/li&gt;
&lt;li&gt;&lt;img src="https://media2.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%2F23aobyz6j106syjmja4i.png" alt="final" width="800" height="681"&gt;&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;/li&gt;

&lt;li&gt;Let's run this.

&lt;ol&gt;
&lt;li&gt;Just open the terminal, change the directory to the home directory and inside &lt;code&gt;src&lt;/code&gt; folder, then write  &lt;code&gt;node bot.js&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ol&gt;




&lt;p&gt;Thank you for reading the whole blog 🎉!! If you liked it do share it with your developer friends and feel free to comment and give suggestions.&lt;/p&gt;




</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>npm</category>
      <category>discord</category>
    </item>
    <item>
      <title>How to make neumorphism boxes using CSS</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Sun, 04 Jul 2021 18:51:00 +0000</pubDate>
      <link>https://dev.to/shreyazz/how-to-make-neumorphism-boxes-using-css-1lo7</link>
      <guid>https://dev.to/shreyazz/how-to-make-neumorphism-boxes-using-css-1lo7</guid>
      <description>&lt;p&gt;Hey folks 👋🏻, today we are going to build some squares which are neumorphic in design.&lt;/p&gt;

&lt;p&gt;Now you may ask.. What? why are we building squares? believe me, this technique of design can be used anywhere and it will make your website aesthetically pleasing.&lt;/p&gt;

&lt;p&gt;Okay, so before we get started let's understand what is neumorphism, it is a design trend which looks very minimal and gives a soft feel to the UI.&lt;/p&gt;

&lt;p&gt;This is how it looks: &lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/shreyas13/embed/GRmpZyb?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;strong&gt;👆🏻 This may not look nice in the preview, so please open the results in a new tab.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this design theme, we just have to play around &lt;code&gt;box-shadow&lt;/code&gt; and make a light-source and a dark shadow, now you might not understand this by now but you will, when you see how easy the steps are.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE: Before reading the steps, I have given the reference from the codepen's CSS section. So if you don't understand any property do refer to the CSS or comment down below!&lt;/strong&gt;&lt;/p&gt;



&lt;h3&gt;
  
  
  Steps:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Give the body a &lt;code&gt;background-color&lt;/code&gt; in this case I have given &lt;code&gt;rgb(194, 194, 194);&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Make four &lt;code&gt;divs&lt;/code&gt; with different class names.&lt;/li&gt;
&lt;li&gt;Apply the same &lt;code&gt;background-color&lt;/code&gt; to the &lt;code&gt;div&lt;/code&gt; tags as the body, which is &lt;code&gt;rgb(194, 194, 194);&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The first box (from the left), is looking like it is lifted of the screen. 

&lt;ol&gt;
&lt;li&gt;This is achieved by providing a light source from the &lt;code&gt;top-left&lt;/code&gt; and making a dark shadow on the &lt;code&gt;bottom-right&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;The light source has to be a little lighter than the background color, usually a color close to white.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;box-shadow&lt;/code&gt;  is &lt;code&gt;box-shadow: 20px 20px 60px #8d8d8d71, -20px -20px 60px #e0e0e0;&lt;/code&gt;, here the negative values indicate the light-source coming from top-left and the positive values represent the dark-shadow formed at the bottom-right.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;The second box's (from left) corners are lifted and are emerging out of the screen.

&lt;ol&gt;
&lt;li&gt;This effect is somewhat the same as the first one, but the only difference is here we are giving a &lt;code&gt;linear-gradient&lt;/code&gt; to the box which is &lt;strong&gt;opposite&lt;/strong&gt;  to the &lt;code&gt;box-shadow&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In simpler terms the top-left corner has a light-source i.e. a light shadow an inside is a dark &lt;code&gt;background-color&lt;/code&gt; and vice-versa on the opposite corner.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;The third box (from-left) looks like it is about to emerge from the screen.

&lt;ol&gt;
&lt;li&gt;This is the exact opposite to the previous one. The only difference is the colors of &lt;code&gt;linear-gradient&lt;/code&gt; are sw apped. &lt;/li&gt;
&lt;li&gt;The lighter-shadow side (&lt;code&gt;top-left&lt;/code&gt;) has a light color and the darker-shadow side (&lt;code&gt;bottom-right&lt;/code&gt;) has a dark color.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;The fourth box (right-most) is looking like it is pressed inside the screen and is hollow. 

&lt;ol&gt;
&lt;li&gt;This is done by just &lt;code&gt;box-shadow&lt;/code&gt; but on the  inner side.&lt;/li&gt;
&lt;li&gt;We can give &lt;code&gt;box-shadow&lt;/code&gt;  on the inner side by using a value called &lt;code&gt;inset&lt;/code&gt; which will help us give the shadow inside.&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;/ol&gt;

&lt;p&gt;That is how easy it was to make these boxes using neumorphism!!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;In my upcoming blogs we are going to see the implementation of glassmorphism and neumorphism!! We are going to build a credit-card using these design themes!!&lt;/em&gt; &lt;/p&gt;




&lt;p&gt;Thank you for reading the whole blog 🎉! If you liked it, do share it with your friends and implement this design in your projects! &lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>codepen</category>
      <category>css</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Make a glass-morph card in less than 5 minutes!</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Thu, 01 Jul 2021 09:14:26 +0000</pubDate>
      <link>https://dev.to/shreyazz/make-a-glass-morph-card-in-less-than-5-minutes-3ap6</link>
      <guid>https://dev.to/shreyazz/make-a-glass-morph-card-in-less-than-5-minutes-3ap6</guid>
      <description>&lt;p&gt;Hey everyone 👋🏻, today we are going to make a glass morphism card using only HTML and CSS!&lt;/p&gt;

&lt;p&gt;Now what is &lt;em&gt;glass morphism&lt;/em&gt;, it is a UI trend which was trending in recent times and is very very easy to make, so without wasting any time let's get started 👩🏻‍💻.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/shreyas13/embed/YzVXPYL?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps to make a glass-morph card :
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Make a &lt;code&gt;div&lt;/code&gt; with a linear gradient(not necessary) or make any shape, this shape will go behind the card to make it look translucent. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make the &lt;code&gt;div&lt;/code&gt; with a class of &lt;code&gt;card&lt;/code&gt;, give it some width and height, center it on the screen using &lt;code&gt;position: absolute;&lt;/code&gt; or &lt;code&gt;display: flex&lt;/code&gt; whichever method you like. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now there are 2 main properties to be applied on the card, which will make it look like translucent object, the properties are :&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;background&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;linear-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
    &lt;span class="err"&gt;101&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="err"&gt;96&lt;/span&gt;&lt;span class="nt"&gt;deg&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="nt"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;249&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="err"&gt;249&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="err"&gt;249&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="err"&gt;261&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nt"&gt;-0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="err"&gt;52&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt;
    &lt;span class="nt"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;249&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="err"&gt;249&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="err"&gt;249&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="err"&gt;0775668&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="err"&gt;88&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="err"&gt;4&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt;
    &lt;span class="nt"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;249&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="err"&gt;249&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="err"&gt;249&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="err"&gt;058&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="err"&gt;25&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;
  &lt;span class="o"&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 css"&gt;&lt;code&gt;  &lt;span class="nt"&gt;backdrop-filter&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;blur&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;20&lt;/span&gt;&lt;span class="nt"&gt;px&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; &lt;span class="c"&gt;/* some browsers don't support this property but if you still wanna try it out then use chrome */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it you have made a glass-morph card on your own 🥳!! Wasn't that easy?!!&lt;/p&gt;




&lt;h2&gt;
  
  
  Thank you for reading the whole blog 🎉, and if you found it helpful then do implement this in your projects!!
&lt;/h2&gt;

&lt;p&gt;// connect: &lt;br&gt;
&lt;a href="https://linktr.ee/shreyazz" rel="noopener noreferrer"&gt;My Socials&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>tutorial</category>
      <category>codepen</category>
    </item>
    <item>
      <title>Arrow Functions</title>
      <dc:creator>Shreyas Pahune</dc:creator>
      <pubDate>Wed, 23 Jun 2021 20:39:49 +0000</pubDate>
      <link>https://dev.to/shreyazz/arrow-functions-4d77</link>
      <guid>https://dev.to/shreyazz/arrow-functions-4d77</guid>
      <description>&lt;p&gt;Hey everyone 👋🏻, in this blog we are going  to discuss about :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arrow Functions V/S Regular Functions&lt;/li&gt;
&lt;li&gt;Advantages and Disadvantages of using Arrow Functions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Like I said in my &lt;a href="https://dev.to/shreyazz/es6-features-1ao8"&gt;previous blog&lt;/a&gt;, the arrow function is not a new concept, it is just a syntax revamp of the regular function in JS. The new syntax is very very easy, it is just a sugar coating around the old function syntax so without wasting anymore time let's start learning about arrow functions!&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Arrow Functions V/S Regular Functions
&lt;/h3&gt;

&lt;p&gt;We are going to discuss 4 different types of functions and we'll transform them from the old rusty ES5 syntax to ES6 syntax. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4 different types are going to be:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;  1. A named function with no parameters.&lt;br&gt;
    2. A named function with one parameter.&lt;br&gt;
    3. A named function with two parameters.&lt;br&gt;
    4. An unnamed function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Named function with no parameters :&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.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%2Fz1fqt455qii416tcvwbj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fz1fqt455qii416tcvwbj.png" alt="nameFunctionNoParam" width="800" height="592"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;As you can see in the above photo, we have to give the name of the function as a variable name and after an equal symbol &lt;code&gt;=&lt;/code&gt;  an opening and closing parenthesis &lt;code&gt;( )&lt;/code&gt; which will denote the function, leading with an arrow  &lt;code&gt;=&amp;gt;&lt;/code&gt; which is nothing but an equal sign and angular bracket. &lt;/p&gt;

&lt;p&gt;There is another way of making an one liner arrow function, you just have to give the function name as a variable name and &lt;code&gt;=&lt;/code&gt; sign leading with &lt;code&gt;=&amp;gt;&lt;/code&gt; arrow and the statement you want to return.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Named function with one parameter :&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.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%2Fizexel95gc0dsvmajz55.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fizexel95gc0dsvmajz55.png" alt="nameFunctionOneParam" width="800" height="558"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;There is no change except in the parenthesis &lt;code&gt;( )&lt;/code&gt;  in which we will pass our parameters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Named function with two parameters :&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.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%2Fhjeetfq6qtvh1q1xpsev.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fhjeetfq6qtvh1q1xpsev.png" alt="nameFunctionTwoParam" width="800" height="558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Unnamed function :&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media2.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%2F095g64q6944lpenxudop.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F095g64q6944lpenxudop.png" alt="unamedFunction" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
Isn't this cool??&lt;/p&gt;

&lt;h3&gt;
  
  
  2.  Advantages and Disadvantages of using Arrow Functions
&lt;/h3&gt;

&lt;p&gt;Arrow functions make our code more concise and increases the readability of the code, the new syntax is really easy to adopt and takes no time to understand things.&lt;/p&gt;

&lt;p&gt;Apart from writing less and doing more Arrow Function can help us with &lt;code&gt;this&lt;/code&gt; keyword and scoping of variables, let me show you how.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F4mbz12bortj1u7hgatbj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F4mbz12bortj1u7hgatbj.png" alt="classThis" width="800" height="626"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here in this above image I have made a class with 2 member functions, arrow and regular which consists of &lt;code&gt;setTimeout&lt;/code&gt; to make a block of code so that we can see the scope of  &lt;code&gt;this&lt;/code&gt;  keyword using arrow functions v/s regular function.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Here we will receive the name(Shreyas) and age(18) in the arrow function, as inside this function &lt;code&gt;this&lt;/code&gt; keyword will use the scope where it was created ( i.e. inside the class ) but on the other hand the regular function will use the scope where it is invoked or called i.e. which is outside the class and since  there is no name and age defined outside the class, we will receive &lt;code&gt;undefined&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One disadvantage I feel is, we can not use arrow function to define constructor. &lt;/p&gt;

&lt;p&gt;A constructor is a special function which is to be made inside every class, which basically sets default values and initializes them.&lt;/p&gt;

&lt;p&gt;In the above example you can see I have made a constructor function, but with normal function's syntax.&lt;/p&gt;




&lt;p&gt;Thank you so much for reading the whole blog 🎉! I hope you learnt something and if you did, do implement it, it would make your code more concise and readable. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>codequality</category>
    </item>
  </channel>
</rss>
