<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Gurnav224</title>
    <description>The latest articles on Forem by Gurnav224 (@gurnav224).</description>
    <link>https://forem.com/gurnav224</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%2F490404%2F36ee4ce6-c0cf-41b6-824f-82c3082d6035.jpg</url>
      <title>Forem: Gurnav224</title>
      <link>https://forem.com/gurnav224</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/gurnav224"/>
    <language>en</language>
    <item>
      <title>JWT Made Easy: A Beginner’s Guide to Authentication</title>
      <dc:creator>Gurnav224</dc:creator>
      <pubDate>Tue, 15 Jul 2025 04:40:22 +0000</pubDate>
      <link>https://forem.com/gurnav224/jwt-made-easy-a-beginners-guide-to-authentication-1kp6</link>
      <guid>https://forem.com/gurnav224/jwt-made-easy-a-beginners-guide-to-authentication-1kp6</guid>
      <description>&lt;h2&gt;
  
  
  📝 Introduction
&lt;/h2&gt;

&lt;p&gt;Authentication is a key part of almost every web application today, and JSON Web Tokens (JWT) offer a modern, stateless, and secure way to manage it. If you’ve ever wondered how websites keep you logged in or verify who you are behind the scenes, chances are JWT is involved. &lt;/p&gt;

&lt;p&gt;In this article, we’ll break down what JWT is, how it works, and how you can use it to protect your routes and user data. Don’t worry—this guide is written with beginners in mind, with simple code examples and clear explanations.&lt;/p&gt;

&lt;h2&gt;
  
  
  ✅ What You’ll Learn in This Article
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What is JWT and why it’s used&lt;/li&gt;
&lt;li&gt;The structure of a JWT (Header, Payload, Signature)&lt;/li&gt;
&lt;li&gt;How to generate a token using jwt.sign()&lt;/li&gt;
&lt;li&gt;How to decode and verify the token using middleware&lt;/li&gt;
&lt;li&gt;Real-world use case: authenticating users in a Node.js app&lt;/li&gt;
&lt;li&gt;Common mistakes and best practices when using JWT&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🔐 What is JWT and Why It’s Used
&lt;/h3&gt;

&lt;p&gt;JWT stands for JSON Web Token — a secure and compact way to send user information between a client and a server. Once a user logs in, the server creates a token containing user data, signs it using a secret key, and sends it back to the client. The client then includes this token in future requests to prove they are authenticated.&lt;/p&gt;

&lt;p&gt;JWT is commonly used in stateless authentication. This means the server doesn’t need to remember who the user is—everything is stored in the token and verified on each request.&lt;/p&gt;




&lt;h3&gt;
  
  
  🧬 The Structure of a JWT
&lt;/h3&gt;

&lt;p&gt;A JWT is made up of three parts, separated by dots (&lt;code&gt;.&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Header.Payload.Signature
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  1. 🧾 Header
&lt;/h4&gt;

&lt;p&gt;The header typically contains two pieces of information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The type of the token (always JWT)&lt;/li&gt;
&lt;li&gt;The signing algorithm (like HS256)
&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="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alg&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;HS256&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;typ&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;JWT&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;h4&gt;
  
  
  2. 📦 Payload
&lt;/h4&gt;

&lt;p&gt;The payload contains the actual data (also called claims), such as the user ID or username. You can add custom data too.&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="p"&gt;{&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username&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;gurnav&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;iat&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1625674832&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;exp&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1625678432&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;iat: Issued At – when the token was created.&lt;/li&gt;
&lt;li&gt;exp: Expiration – when the token will expire.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. 🔐 Signature
&lt;/h4&gt;

&lt;p&gt;The signature is created by combining the header, payload, and a secret key. It ensures that the token wasn’t tampered with.&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="nc"&gt;HMACSHA256&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nf"&gt;base64UrlEncode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;header&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&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="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;base64UrlEncode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nx"&gt;secret_key&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If someone tries to change the data in the payload, the signature won’t match, and the token will be rejected.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔐 How to Generate a Token Using jwt.sign()
&lt;/h3&gt;

&lt;p&gt;After a user successfully logs in (by entering the correct email and password, for example), we usually want  to create a token to identify them in future requests. This is where jwt.sign() comes in.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;secretKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;options&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;payload: Object with user info like ID, username, role, etc.&lt;/li&gt;
&lt;li&gt;secretKey: A string used to sign the token (keep this private!)&lt;/li&gt;
&lt;li&gt;options: An object with additional settings like expiresIn&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  💡 Code Example: Creating a JWT Token in Node.js
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;jwt&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;jsonwebtoken&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;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;gurnav&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;secretKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my_secret_key&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;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;secretKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;expiresIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1h&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="s1"&gt;Generated Token:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;Generated Token&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This token can now be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sent back to the client&lt;/li&gt;
&lt;li&gt;Stored in localStorage or cookies&lt;/li&gt;
&lt;li&gt;Used in future requests as a proof of identity&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  📌 Real-World Use Case
&lt;/h3&gt;

&lt;p&gt;In a real application, you'd generate this token after verifying the user's credentials:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/login&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&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;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Fake user authentication (replace with DB check)&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;gurnav&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;123456&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;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;secretKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;expiresIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1h&lt;/span&gt;&lt;span class="dl"&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;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Login successful&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="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;401&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="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid credentials&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🛡️ How to Verify a JWT Token Using Middleware
&lt;/h3&gt;

&lt;p&gt;Once a token is created and sent to the client, it’s included in every protected request—usually in the Authorization header or cookie. The server then verifies this token to check if the user is authenticated and allowed to access the route.&lt;/p&gt;

&lt;p&gt;We use a middleware function in Node.js (Express) to handle this verification.&lt;/p&gt;

&lt;h4&gt;
  
  
  ✅ Middleware Code Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;jwt&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;jsonwebtoken&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;secretKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my_secret_key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;authenticateToken&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="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Get the token from the Authorization header&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;authHeader&lt;/span&gt; &lt;span class="o"&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;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;authorization&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;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;authHeader&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;authHeader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="c1"&gt;// Bearer &amp;lt;token&amp;gt;&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;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;401&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="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Access token missing&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="c1"&gt;// Verify the token&lt;/span&gt;
  &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;verify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;secretKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;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;403&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="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid or expired token&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;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Attach the user info to the request&lt;/span&gt;
    &lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Proceed to the next middleware or route&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;h4&gt;
  
  
  📌 How to Use the Middleware
&lt;/h4&gt;

&lt;p&gt;You can use this authenticateToken middleware on any route you want to protect&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;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;/dashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;authenticateToken&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;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Welcome &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;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;username&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="na"&gt;user&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;user&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;Now only users with a valid JWT token will be able to access /dashboard.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔒 Key Points
&lt;/h3&gt;

&lt;p&gt;Tip: Always send tokens from the frontend using the Authorization: Bearer  header.&lt;/p&gt;

&lt;p&gt;The jwt.verify() function will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Decode the token"&lt;/li&gt;
&lt;li&gt;"Check its signature"&lt;/li&gt;
&lt;li&gt;"Check for expiration (exp)"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If valid, you can access the decoded user info via req.user&lt;/p&gt;

&lt;h1&gt;
  
  
  🏁 Conclusion
&lt;/h1&gt;

&lt;p&gt;JWT makes authentication in web applications simple, secure, and scalable—especially for APIs and SPAs. In this article, you learned how to create, structure, and verify JWTs using Node.js.&lt;/p&gt;

&lt;p&gt;Now you’re ready to secure your routes like a pro! 🚀&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title># What Are the Different Types of Errors in JavaScript?</title>
      <dc:creator>Gurnav224</dc:creator>
      <pubDate>Sat, 31 May 2025 08:32:14 +0000</pubDate>
      <link>https://forem.com/gurnav224/-what-are-the-different-types-of-errors-in-javascript-40b7</link>
      <guid>https://forem.com/gurnav224/-what-are-the-different-types-of-errors-in-javascript-40b7</guid>
      <description>&lt;p&gt;In JavaScript, errors are inevitable parts of programming. They act as helpful messages that let us know when something has gone wrong. JavaScript provides a built-in &lt;code&gt;Error&lt;/code&gt; object that contains valuable information about the error. Understanding the types of errors and their causes is crucial for debugging and writing robust code.&lt;/p&gt;

&lt;p&gt;Let’s explore some of the most common types of errors in JavaScript: &lt;strong&gt;Syntax Error&lt;/strong&gt;, &lt;strong&gt;Reference Error&lt;/strong&gt;, and &lt;strong&gt;Type Error&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. Syntax Error
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;Syntax Error&lt;/strong&gt; occurs when we write code that does not follow the correct syntax rules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello world&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Reason:&lt;/strong&gt; There’s a missing closing parenthesis. The JavaScript engine cannot parse this code.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reference Error
A Reference Error occurs when we try to access a variable or function that has not been defined.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;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;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reason: The variable a is not declared.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Type Error&lt;/strong&gt;
A Type Error occurs when a value is used in an unexpected way or is of an unexpected type.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here are a few common reasons why Type Errors occur:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Calling a non-function
If we try to invoke a variable as a function, but it is not actually a function, a Type Error will be thrown.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="nf"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// TypeError: obj is not a function&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Accessing properties of undefined or null
This error occurs when we try to access a property of a variable that is undefined or null.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;myVar&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;myVar&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;// TypeError: Cannot read property 'name' of undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Modifying a constant variable
A Type Error also occurs when we try to change a constant variable’s value.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&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;// TypeError: Assignment to constant variable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Approach Any Coding Problem or Development Task</title>
      <dc:creator>Gurnav224</dc:creator>
      <pubDate>Sat, 31 May 2025 06:43:26 +0000</pubDate>
      <link>https://forem.com/gurnav224/how-to-approach-any-coding-problem-or-development-task-16be</link>
      <guid>https://forem.com/gurnav224/how-to-approach-any-coding-problem-or-development-task-16be</guid>
      <description>&lt;p&gt;To tackle any coding problem or develop new features effectively, there are a few things you should prepare before jumping straight into coding.&lt;/p&gt;

&lt;p&gt;The most important first step is &lt;strong&gt;understanding the problem or the feature requirements&lt;/strong&gt;. If you don’t fully grasp what’s being asked, you won’t be able to solve it effectively.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Read and Understand the Problem
&lt;/h2&gt;

&lt;p&gt;Read the problem carefully, focusing on what’s given and what you need to solve. Clarify any confusing parts and make sure you understand the scope of the problem.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: Plan Your Approach
&lt;/h2&gt;

&lt;p&gt;Before diving into the code, take some time to plan out your solution. Ask yourself questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What functionality do I need to develop?&lt;/li&gt;
&lt;li&gt;Does it involve a user interface? If yes, sketch a rough layout.&lt;/li&gt;
&lt;li&gt;What are the inputs and expected outputs?&lt;/li&gt;
&lt;li&gt;Will I need to get user input to generate the desired output?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This planning phase will help you avoid confusion later.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: Write Pseudocode
&lt;/h2&gt;

&lt;p&gt;Writing pseudocode helps you think through the problem in plain English (or any language you’re comfortable with!). It forces you to slow down and figure out the steps you’ll need in your actual code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example pseudocode: Checking if a user is eligible to drive&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Take user’s age as input.
Store the user’s age in a variable called user_age.
Check if the user is eligible:
If user_age &amp;gt; 18:
Print “You are eligible to drive.”
Else:
Print “You are not eligible to drive.”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 4: Divide and Conquer
&lt;/h2&gt;

&lt;p&gt;Breaking big problems into smaller sub-problems makes them easier to solve. Here’s how it might look:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem Statement:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Check if a user is eligible to drive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sub-problems:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
✅ Take user input (age).&lt;br&gt;&lt;br&gt;
✅ Check if &lt;code&gt;age &amp;gt; 18&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
✅ If true, print “You are eligible to drive.”&lt;br&gt;&lt;br&gt;
✅ Else, print “You are not eligible to drive.”&lt;/p&gt;




&lt;p&gt;By following these steps—&lt;strong&gt;understand&lt;/strong&gt;, &lt;strong&gt;plan&lt;/strong&gt;, &lt;strong&gt;pseudocode&lt;/strong&gt;, and &lt;strong&gt;break down&lt;/strong&gt;—you’ll find coding and development tasks much more approachable and easier to handle!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>How javascript engine excuted the Javascript code</title>
      <dc:creator>Gurnav224</dc:creator>
      <pubDate>Thu, 29 May 2025 10:14:38 +0000</pubDate>
      <link>https://forem.com/gurnav224/how-javascript-engine-excuted-the-javascript-code-4g9</link>
      <guid>https://forem.com/gurnav224/how-javascript-engine-excuted-the-javascript-code-4g9</guid>
      <description>&lt;p&gt;JavaScript code runs within the JavaScript engine, such as V8 in Chrome or SpiderMonkey in Firefox. or Node.js&lt;br&gt;
The engine will take care of the code execution life cycle like parsing, compilation, and execution&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Parsing:&lt;/strong&gt; In the first phase, the engine will parse the JavaScript code into an AST abstract &lt;br&gt;
syntax tree structure&lt;/p&gt;

&lt;p&gt;before parsing &lt;br&gt;
&lt;code&gt;&lt;br&gt;
let a = 5;&lt;br&gt;
let b = 10;&lt;br&gt;
let sum = a + b;&lt;br&gt;
console.log(sum);&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;after parsing&lt;br&gt;
&lt;code&gt;&lt;br&gt;
Program&lt;br&gt;
├── VariableDeclaration (let a = 5)&lt;br&gt;
│   ├── Identifier (a)&lt;br&gt;
│   └── Literal (5)&lt;br&gt;
├── VariableDeclaration (let b = 10)&lt;br&gt;
│   ├── Identifier (b)&lt;br&gt;
│   └── Literal (10)&lt;br&gt;
├── VariableDeclaration (let sum = a + b)&lt;br&gt;
│   ├── Identifier (sum)&lt;br&gt;
│   └── BinaryExpression (+)&lt;br&gt;
│       ├── Identifier (a)&lt;br&gt;
│       └── Identifier (b)&lt;br&gt;
└── ExpressionStatement (console.log(sum))&lt;br&gt;
    ├── MemberExpression (console.log)&lt;br&gt;
    │   ├── Identifier (console)&lt;br&gt;
    │   └── Identifier (log)&lt;br&gt;
    └── Identifier (sum)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. compilation phase&lt;/strong&gt;: in this phase engine compile the AST into byte code or machine code&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;modern day javascript engine use JIT or JUST-in-time compliation to make the excution faster&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. excution phase :&lt;/strong&gt; in the excution phase engine excuted the compile code&lt;br&gt;
 call stack keep track of the function call which function currenlty excuted &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>SQL vs NoSQL</title>
      <dc:creator>Gurnav224</dc:creator>
      <pubDate>Sat, 24 May 2025 04:15:47 +0000</pubDate>
      <link>https://forem.com/gurnav224/sql-vs-nosql-4h8p</link>
      <guid>https://forem.com/gurnav224/sql-vs-nosql-4h8p</guid>
      <description>&lt;h2&gt;
  
  
  SQL vs NoSQL
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SQL&lt;/strong&gt;: SQL databases store data in tables consisting of rows and columns, similar to spreadsheets.&lt;br&gt;
They are designed to handle structured data with support for constraints and data integrity.&lt;br&gt;
When new data is added, it typically grows vertically as new rows are inserted.&lt;/p&gt;

&lt;p&gt;Key Points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;constraints&lt;/code&gt;&lt;/strong&gt;: Rules for data definition like primary key, foreign key, and not null that ensure data validity&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;data integrity&lt;/code&gt;&lt;/strong&gt;: Maintained through constraints and transactions to prevent invalid or inconsistent data&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;vertical growth&lt;/code&gt;&lt;/strong&gt;: Adding records means adding rows (not columns)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;NoSQL&lt;/strong&gt;: NoSQL databases store data in a document-based, schemaless format, typically using BSON (Binary JSON). Data is represented as key-value pairs, making these databases well-suited for unstructured or semi-structured data.&lt;/p&gt;

&lt;p&gt;They are designed to handle frequent and dynamic data changes, making them ideal for scenarios like analytics, social media posts, and real-time applications.&lt;/p&gt;

&lt;p&gt;When new data is added, NoSQL databases typically grow horizontally—by adding more documents or nodes, rather than modifying the structure.&lt;/p&gt;

&lt;p&gt;Key Points: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Schemaless&lt;/code&gt;&lt;/strong&gt;: No fixed schema; documents can have different fields&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Horizontal Growth&lt;/code&gt;&lt;/strong&gt;: New data means adding more documents (not fields/columns)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;Ideal Use Cases&lt;/code&gt;&lt;/strong&gt;: Unpredictable or fast-changing data like user-generated content, logs, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Real-World Applications Use Both Types of Databases According to Their Use Case
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Example 1: Flipkart
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;SQL Uses&lt;/em&gt;: Used when data is highly structured and relationships between entities are important.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Categories have a well-defined structure: id, name, parent_category_id, etc.&lt;/li&gt;
&lt;li&gt;Easy to represent with foreign keys (e.g., subcategories reference parent categories)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;NoSQL Uses&lt;/em&gt;: Used for flexible, high-volume, and fast access data, often with denormalized structures.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each product can have varying attributes depending on category (e.g., phones have battery capacity; clothes have size, color)&lt;/li&gt;
&lt;li&gt;Storing in a document format (like in MongoDB) allows flexible schema per product&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example 2: Netflix Hybrid Architecture
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;SQL Uses&lt;/em&gt;: Netflix uses SQL to store metadata management (e.g., movie title, genre), billing and subscriptions, and user accounts and profiles&lt;/p&gt;

&lt;p&gt;&lt;em&gt;NoSQL Uses&lt;/em&gt;: Netflix uses NoSQL to store user activity logs, playback events, recommendations, and device and session management&lt;/p&gt;

&lt;h4&gt;
  
  
  Example 3: Uber's Hybrid Data Architecture
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;SQL Uses&lt;/em&gt;: Uber uses SQL databases (like MySQL or PostgreSQL) to store structured and relational data such as user accounts, ride history, driver profiles, and static relational data&lt;/p&gt;

&lt;p&gt;&lt;em&gt;NoSQL Uses&lt;/em&gt;: Uber uses NoSQL databases (like Apache Cassandra) for storing data like trip state management (live updates) and user-trip interactions (real-time locations, status)&lt;/p&gt;

&lt;h3&gt;
  
  
  Why We Use SQL and NoSQL
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;SQL&lt;/code&gt;: We use SQL databases to efficiently handle structured and relational data, where the schema is well-defined and data consistency is critical (e.g., user accounts, transactions, relationships between tables).&lt;br&gt;
&lt;code&gt;NoSQL&lt;/code&gt;: We use NoSQL databases to handle unstructured or semi-structured data, non-relational data models, and highly dynamic or large-scale data that changes frequently. NoSQL is ideal for use cases requiring flexibility, horizontal scalability, and fast read/write performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is CAP Theorem?
&lt;/h3&gt;

&lt;p&gt;CAP Theorem is a principle in distributed systems that says:&lt;br&gt;
    A distributed system can only guarantee two out of these three things at the same time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;C — Consistency&lt;/code&gt;: Every user sees the same data no matter which server they connect to.&lt;br&gt;
Example: You book a cab, and your friend no longer sees that cab as available—because the system has updated everywhere at the same time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;A — Availability&lt;/code&gt;: The system always responds, even if it can't give the most up-to-date data.&lt;br&gt;
Example: You always get a ride request response—even if the data might be slightly outdated.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;P — Partition Tolerance&lt;/code&gt;: The system keeps working even if there's a network issue or some servers can't talk to each other.&lt;br&gt;
Example: If two Uber servers in different cities can't communicate, both still handle local requests.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>What type of language JavaScript Is?</title>
      <dc:creator>Gurnav224</dc:creator>
      <pubDate>Tue, 15 Apr 2025 04:32:43 +0000</pubDate>
      <link>https://forem.com/gurnav224/what-type-of-language-javascript-is-3bf3</link>
      <guid>https://forem.com/gurnav224/what-type-of-language-javascript-is-3bf3</guid>
      <description>&lt;p&gt;JavaScript is a &lt;strong&gt;single-threaded&lt;/strong&gt;, &lt;strong&gt;dynamically typed&lt;/strong&gt;, interpreted programming language that supports multiple programming paradigms, including object-oriented, functional, and imperative styles. Its features provide prototype-based object orientation and an event-driven architecture. making it well-suited for building interactive and asynchronous web applications.&lt;/p&gt;

&lt;p&gt;didn't get much idea with this definition, let's explore  each part of it's definition in details&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧵Single Threaded:&lt;/strong&gt; JavaScript is &lt;strong&gt;single-threaded&lt;/strong&gt;, meaning it has only &lt;strong&gt;one main thread of execution&lt;/strong&gt;. This means it uses a &lt;strong&gt;single call stack&lt;/strong&gt; to manage function execution.&lt;/p&gt;

&lt;p&gt;When a function is called, it is &lt;strong&gt;pushed onto the top&lt;/strong&gt; of the call stack. Once the function finishes executing, it is &lt;strong&gt;popped off the stack&lt;/strong&gt;, and control returns to the next item below. JavaScript code is executed in a sequential manner, one step at a time.&lt;/p&gt;

&lt;p&gt;Despite being single-threaded, JavaScript provides Web APIs (like setTimeout, fetch, and Event Listeners) that allow asynchronous operations. These APIs work with the event loop and callback queue to handle asynchronous tasks without blocking the main thread.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;console.log&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Start"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

setTimeout&lt;span class="o"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  console.log&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Inside setTimeout"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; // runs later
&lt;span class="o"&gt;}&lt;/span&gt;, 1000&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

console.log&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"End"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

// Output:
// Start
// End
// Inside setTimeout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Dyamically Type:&lt;/strong&gt;&lt;br&gt;
In JavaScript, variables are not explicitly declared with a type. Instead, their types are inferred from the values assigned to them at runtime. This means a variable can hold a value of one type and later be reassigned to a value of a completely different type during the program’s execution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;let &lt;/span&gt;data &lt;span class="o"&gt;=&lt;/span&gt; 10&lt;span class="p"&gt;;&lt;/span&gt;       // data is a number
data &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      // now it&lt;span class="s1"&gt;'s a string
data = true;         // now it'&lt;/span&gt;s a boolean

console.log&lt;span class="o"&gt;(&lt;/span&gt;typeof data&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; // Output: boolean

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This flexibility makes JavaScript powerful but also prone to type-related bugs if not handled carefully.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Interpreted Language&lt;/strong&gt;: &lt;br&gt;
JavaScript is an interpreted language, which means the code is read, interpreted, and executed line by line at runtime, rather than being compiled ahead of time like some other languages (e.g., C++ or Java).&lt;/p&gt;

&lt;p&gt;However, modern JavaScript engines in browsers (like V8 in Chrome) use Just-In-Time (JIT) compilation to enhance performance. JIT compiles frequently used code on the fly during execution, combining the benefits of both interpretation and compilation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;let &lt;/span&gt;message &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Hello, Gurnav!"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
console.log&lt;span class="o"&gt;(&lt;/span&gt;message&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; // Output: Hello, Gurnav!

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Object Oriented:&lt;/strong&gt; Object-Oriented Programming (OOP) is a paradigm that organizes code around objects, which are instances of classes. JavaScript supports OOP by allowing you to create and work with objects to encapsulate data and behavior.&lt;/p&gt;

&lt;p&gt;Although the class syntax was introduced in ES6 (ECMAScript 2015) for cleaner and more familiar OOP syntax, JavaScript is fundamentally built on prototype-based inheritance under the hood.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;class Person &lt;span class="o"&gt;{&lt;/span&gt;
  constructor&lt;span class="o"&gt;(&lt;/span&gt;name&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    this.name &lt;span class="o"&gt;=&lt;/span&gt; name&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  greet&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    console.log&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;Hi, I&lt;span class="s1"&gt;'m ${this.name}`);
  }
}

const user = new Person("Gurnav");
user.greet(); // Output: Hi, I'&lt;/span&gt;m Gurnav

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Imperative Programming:&lt;/strong&gt; &lt;br&gt;
Imperative programming is a programming paradigm that focuses on how to perform tasks step by step using explicit statements and control flow (like loops, conditionals, and assignments).&lt;/p&gt;

&lt;p&gt;In this style, you tell the computer what to do and how to do it, modifying program state along the way.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;const numbers &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;1, 2, 3, 4]&lt;span class="p"&gt;;&lt;/span&gt;
const doubled &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;let &lt;/span&gt;i &lt;span class="o"&gt;=&lt;/span&gt; 0&lt;span class="p"&gt;;&lt;/span&gt; i &amp;lt; numbers.length&lt;span class="p"&gt;;&lt;/span&gt; i++&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  doubled.push&lt;span class="o"&gt;(&lt;/span&gt;numbers[i] &lt;span class="k"&gt;*&lt;/span&gt; 2&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

console.log&lt;span class="o"&gt;(&lt;/span&gt;doubled&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; // &lt;span class="o"&gt;[&lt;/span&gt;2, 4, 6, 8]

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Functional Programming:&lt;/strong&gt;&lt;br&gt;
Functional programming is a paradigm where programs are constructed by applying and composing pure functions. It emphasizes what to do rather than how to do it.&lt;/p&gt;

&lt;p&gt;Key principles include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pure functions (no side effects)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Immutability (data is not modified)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;First-class functions (functions can be passed around like variables)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Higher-order functions (functions that take or return other functions)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Function composition: Building complex functionality by combining simpler functions.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;const numbers &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;1, 2, 3, 4]&lt;span class="p"&gt;;&lt;/span&gt;

const doubled &lt;span class="o"&gt;=&lt;/span&gt; numbers.map&lt;span class="o"&gt;(&lt;/span&gt;num &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; num &lt;span class="k"&gt;*&lt;/span&gt; 2&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

console.log&lt;span class="o"&gt;(&lt;/span&gt;doubled&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; // &lt;span class="o"&gt;[&lt;/span&gt;2, 4, 6, 8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;🧬 Prototype-Based Orientation:&lt;/strong&gt;&lt;br&gt;
JavaScript uses prototype-based object orientation, which means that objects inherit directly from other objects, rather than from classes (like in classical OOP languages).&lt;/p&gt;

&lt;p&gt;Every JavaScript object has an internal link to another object called its prototype. When you try to access a property or method that doesn't exist on the object itself, JavaScript looks for it in the object's prototype chain.&lt;/p&gt;

&lt;p&gt;Even the class syntax in JavaScript is just syntactic sugar over this prototype-based inheritance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Person(name) {
  this.name = name;
}

// Adding method to the prototype
Person.prototype.sayHi = function () {
  console.log(`Hi, I'm ${this.name}`);
};

const user = new Person("Gurnav");
user.sayHi(); // Hi, I'm Gurnav

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

&lt;/div&gt;



&lt;p&gt;note: sayHi is not directly on user, but JavaScript finds it through the prototype chain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚡ Event-Driven Architecture:&lt;/strong&gt;&lt;br&gt;
Event-driven architecture is a programming model where the flow of the program is determined by events — such as user actions (clicks, typing), messages from other programs, or timers.&lt;/p&gt;

&lt;p&gt;In JavaScript, especially in the browser environment, this is a core concept. JavaScript uses event listeners to react to events asynchronously without blocking the main thread. This allows for building highly interactive and responsive applications.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&amp;lt;button &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"greetBtn"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;Say Hello&amp;lt;/button&amp;gt;

&amp;lt;script&amp;gt;
  const button &lt;span class="o"&gt;=&lt;/span&gt; document.getElementById&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"greetBtn"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  button.addEventListener&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"click"&lt;/span&gt;, &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    alert&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Hello, Gurnav!"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;})&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, JavaScript listens for the "click" event. When the event happens, the callback function is executed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-world use cases:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Button clicks&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Form submissions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keyboard input&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mouse movements&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;API responses (like fetch)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Timers (setTimeout, setInterval)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Let Understand MERN Stack In Practical way</title>
      <dc:creator>Gurnav224</dc:creator>
      <pubDate>Mon, 08 Apr 2024 06:49:10 +0000</pubDate>
      <link>https://forem.com/gurnav224/let-understand-mern-stack-in-practical-way-4484</link>
      <guid>https://forem.com/gurnav224/let-understand-mern-stack-in-practical-way-4484</guid>
      <description>&lt;p&gt;MERN stands for MongoDB, Express.js, React.js, and Node.js. It's important because it helps us build powerful web applications. &lt;/p&gt;

&lt;p&gt;Imagine we're running a company and we want to keep track of our employees' information, like their names, emails, phone numbers, salaries, and how often they come to work.&lt;/p&gt;

&lt;p&gt;Here's how we can see the information about our employees:&lt;/p&gt;

&lt;p&gt;👀 Look at this table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Email&lt;/th&gt;
&lt;th&gt;Phone&lt;/th&gt;
&lt;th&gt;Salary&lt;/th&gt;
&lt;th&gt;Attendance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;John Smith&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:john.smith@example.com"&gt;john.smith@example.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;+1234567890&lt;/td&gt;
&lt;td&gt;$60,000&lt;/td&gt;
&lt;td&gt;95%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Emily Johnson&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:emily.johnson@example.com"&gt;emily.johnson@example.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;+1987654321&lt;/td&gt;
&lt;td&gt;$55,000&lt;/td&gt;
&lt;td&gt;98%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Michael Brown&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:michael.brown@example.com"&gt;michael.brown@example.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;+1654321890&lt;/td&gt;
&lt;td&gt;$65,000&lt;/td&gt;
&lt;td&gt;92%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sarah Lee&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:sarah.lee@example.com"&gt;sarah.lee@example.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;+1765432980&lt;/td&gt;
&lt;td&gt;$70,000&lt;/td&gt;
&lt;td&gt;96%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;David Wilson&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:david.wilson@example.com"&gt;david.wilson@example.com&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;+1876543210&lt;/td&gt;
&lt;td&gt;$75,000&lt;/td&gt;
&lt;td&gt;97%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  MONGODB
&lt;/h2&gt;

&lt;p&gt;Now, to keep this information safe and organized, we need to put it in a special place called a database. We can use databases like MongoDB or MySQL for this.&lt;/p&gt;

&lt;p&gt;So, MERN helps us make sure all the information about our employees is kept safe and easy to find whenever we need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nodejs
&lt;/h2&gt;

&lt;p&gt;Imagine you have a magical toolbox called Node.js. This toolbox lets you do special things on your computer or server, like making apps or websites. But instead of using regular tools like hammers or screwdrivers, Node.js lets you use JavaScript, the language of the web.&lt;/p&gt;

&lt;p&gt;With Node.js, you can do cool stuff like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run JavaScript Outside of Browsers:&lt;/strong&gt; Normally, JavaScript runs inside web browsers, but with Node.js, you can run JavaScript code directly on your computer or server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Build Web Servers:&lt;/strong&gt; You can create your own web server to handle requests from web browsers, which means you can make your own websites and web apps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Access Files and Databases:&lt;/strong&gt; Node.js lets you read and write files on your computer and connect to databases like MongoDB or MySQL.&lt;/p&gt;

&lt;p&gt;So, Node.js is like a magical toolbox that empowers you to do all sorts of cool things with JavaScript on your computer or server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Express.js:
&lt;/h2&gt;

&lt;p&gt;Now, let's talk about Express.js. Imagine you have a super smart assistant called Express.js. This assistant helps you build web applications quickly and easily.&lt;/p&gt;

&lt;p&gt;Here's how Express.js works:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simplifies Web Development:&lt;/strong&gt; Express.js provides a set of tools and shortcuts to make it easier to build web applications with Node.js. It saves you time and effort by handling common tasks, like routing and handling HTTP requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Middleware:&lt;/strong&gt; Express.js uses middleware, which are like small plugins or functions that you can use to add extra features to your web app, such as authentication, logging, or error handling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Routing:&lt;/strong&gt; With Express.js, you can easily define routes for different URLs in your web app. For example, you can create a route for "/login" to handle user login requests or a route for "/products" to display a list of products.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Integration:&lt;/strong&gt; Express.js works seamlessly with other Node.js modules and libraries, making it easy to add additional functionality to your web app.&lt;/p&gt;

&lt;p&gt;So, Express.js acts as a smart assistant that helps you build web applications faster and with less effort by providing tools, middleware, and routing capabilities.&lt;/p&gt;

&lt;h2&gt;
  
  
  React:
&lt;/h2&gt;

&lt;p&gt;Imagine you have a magical toolkit called React. This toolkit helps you build amazing user interfaces for your websites or web applications. It's like having a set of super-powered building blocks that you can use to create all kinds of cool things on the web.&lt;/p&gt;

&lt;p&gt;With React, you can do awesome stuff like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Component-Based Development:&lt;/strong&gt; React lets you break down your user interface into smaller, reusable components. Each component represents a part of your UI, like a button, form, or header. You can then combine these components to build complex UIs, making your code more modular and easier to maintain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Virtual DOM:&lt;/strong&gt; React uses a virtual representation of the DOM (Document Object Model), which is like a blueprint of your UI. When your data changes, React updates only the parts of the DOM that need to change, making your apps faster and more efficient.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Declarative Syntax:&lt;/strong&gt; React uses a declarative syntax, which means you describe what you want your UI to look like, and React takes care of updating the DOM to match. This makes it easier to reason about your code and write cleaner, more maintainable UIs.&lt;/p&gt;

&lt;p&gt;So, React is like a magical toolkit that empowers you to build interactive and dynamic user interfaces for your web applications with ease.&lt;/p&gt;

&lt;h2&gt;
  
  
  Client:
&lt;/h2&gt;

&lt;p&gt;Now, let's talk about the client. Imagine you have a friendly guide called the client. The client is like a person who interacts with your website or web application using a web browser, like Chrome or Firefox.&lt;/p&gt;

&lt;p&gt;Here's how the client works:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accessing Web Content:&lt;/strong&gt; The client opens a web browser and types in a web address (URL) to access your website or web app. Once connected, the client can view and interact with the content you've created using technologies like HTML, CSS, and JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sending and Receiving Data:&lt;/strong&gt; The client can send requests to your web server to fetch data or perform actions, like submitting a form or logging in. It then receives responses from the server, which it can display or use to update the UI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interactivity:&lt;/strong&gt; The client can interact with your web app by clicking on buttons, filling out forms, or navigating between pages. It can also respond to user input, like keyboard or mouse events, to provide a dynamic and engaging user experience.&lt;/p&gt;

&lt;p&gt;So, the client is like a friendly guide that helps users interact with your website or web application, enabling them to access content, send and receive data, and engage with the UI in meaningful ways.&lt;/p&gt;

&lt;h2&gt;
  
  
  Server:
&lt;/h2&gt;

&lt;p&gt;Imagine you have a helpful butler called the server. The server is like a dedicated assistant that works behind the scenes to handle requests and deliver information to your website or web application.&lt;/p&gt;

&lt;p&gt;Here's how the server works:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling Requests:&lt;/strong&gt; When the client (the person using a web browser) wants to access your website or web app, they send a request to the server. This request includes things like the web address (URL) they want to visit or the data they want to retrieve.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Processing Requests:&lt;/strong&gt; Upon receiving a request, the server swings into action. It processes the request, which might involve fetching data from a database, running calculations, or performing other tasks needed to fulfill the client's request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sending Responses:&lt;/strong&gt; Once the server has processed the request and gathered the necessary information, it sends a response back to the client. This response contains the requested data or instructions on what to display in the web browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Managing Resources:&lt;/strong&gt; The server also manages resources like files, databases, and other services needed to run your website or web app. It ensures that everything runs smoothly and efficiently to provide the best possible experience for users.&lt;/p&gt;

&lt;p&gt;So, the server is like a helpful butler that works tirelessly behind the scenes to handle requests, process data, and deliver information to users, ensuring that your website or web application functions smoothly and reliably.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>How the Web Works ?</title>
      <dc:creator>Gurnav224</dc:creator>
      <pubDate>Mon, 29 May 2023 12:29:45 +0000</pubDate>
      <link>https://forem.com/gurnav224/how-the-web-works--3079</link>
      <guid>https://forem.com/gurnav224/how-the-web-works--3079</guid>
      <description>&lt;p&gt;In this blog , I,ll be writing about the how web works ?&lt;/p&gt;

&lt;p&gt;In short World Wide Web is system of interconnected of documents and resource that accessed all over internet&lt;br&gt;
It allow user to navigate different website and various information ,communicate and engage in various online activities&lt;/p&gt;

&lt;h3&gt;
  
  
  Client :
&lt;/h3&gt;

&lt;p&gt;An Application , such as fire-fox or chrome that runs on a computer and is connected to internet. It primarily focus  to take user interaction translate them into request to another computer called server. we use web browser to access internet in our daily lives. you think your computer as client in client-server model.&lt;/p&gt;

&lt;p&gt;Every client computer has unique address are called Ip address.&lt;br&gt;
Other computer use Ip address to find the computer. &lt;/p&gt;

&lt;h3&gt;
  
  
  Server :
&lt;/h3&gt;

&lt;p&gt;The term server refer to the computer or collection of computers that host requested web resource. The server receives the request message from the client&lt;/p&gt;

&lt;h3&gt;
  
  
  IP Address :
&lt;/h3&gt;

&lt;p&gt;Internet Protocol Address. A numerical identifer for a device such as computer , server , router on A TCP/IP address.&lt;/p&gt;

&lt;p&gt;Every computer on the internet has an Ip address it uses to identify them and communicate with each other. Ip address four set of numbers separated by decimal (eg: 224.155.65.2). This is called logical address. In order to locate device in the network . The logical address is converted into physical address by TCP/IP software. The physical address (eg: MAC ADDRESS) is built into hardware&lt;/p&gt;

&lt;h3&gt;
  
  
  ISP:
&lt;/h3&gt;

&lt;p&gt;Internet Service Provider :  an ISP is company or organization that Provide to access the internet to individual , business, office, school ,etc.&lt;br&gt;
ISP is middle man between client and server .&lt;/p&gt;

&lt;p&gt;When your browser get request from you to go to &lt;a href="http://www.google.com"&gt;www.google.com&lt;/a&gt;, It doesn't know where to look for google.com . so it ISP job to do as DNS (DOMAIN NAME SYSTEM) lookup to ask what IP address the site you trying to visit is configured to &lt;/p&gt;

&lt;h3&gt;
  
  
  DNS
&lt;/h3&gt;

&lt;p&gt;DOMAIN NAME SYSTEM : A distributed database which keep track of computer's domain names and their corresponding IP addresses on the internet &lt;/p&gt;

&lt;p&gt;Domain name : used to identify one or more ip address.&lt;br&gt;
User use the domain name (e.g &lt;a href="http://www.google.com"&gt;www.google.com&lt;/a&gt;) to get the website on the internet. &lt;/p&gt;

&lt;p&gt;when you type the domain name into your browser. the DNS uses it to look up the corresponding ip address for that given website.&lt;/p&gt;

&lt;h3&gt;
  
  
  TCP/IP
&lt;/h3&gt;

&lt;p&gt;Transmission Control Protocol / Internet Protocol . The most widely used communications protocol . TCP/IP is used as a standard for transmitting data over networks. &lt;/p&gt;

&lt;h3&gt;
  
  
  PORT Number
&lt;/h3&gt;

&lt;p&gt;A 16-bit integer that identifies a specific port on a server and is &lt;br&gt;
always associated with an IP address . It servers as a way to identify&lt;br&gt;&lt;br&gt;
a specific process on a server that network requests could be forwarded to &lt;/p&gt;

&lt;h3&gt;
  
  
  Host
&lt;/h3&gt;

&lt;p&gt;A computer connected to a network- It can be client, server or any other type of device. each host has unique ip address. we need host to put our website online access everywhere 24/7&lt;/p&gt;

&lt;h3&gt;
  
  
  HTTP
&lt;/h3&gt;

&lt;p&gt;Hyper-text Transfer Protocol. The protocol that web browsers and web servers use to communicate with each other over the internet. &lt;/p&gt;

&lt;h3&gt;
  
  
  URL
&lt;/h3&gt;

&lt;p&gt;Uniform Resource Locators . URLs Identify  a particular web resource . &lt;br&gt;
A example &lt;a href="https://github.com/someone"&gt;https://github.com/someone&lt;/a&gt;. The URL specifies the protocol ("https"), host name (github.com) and file name (someone profile page). &lt;/p&gt;

&lt;p&gt;A use can obtained the web resource identified by this URL via HTTP from a network host whose domain name is github.com&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>What is Internet ?</title>
      <dc:creator>Gurnav224</dc:creator>
      <pubDate>Sun, 28 May 2023 04:58:29 +0000</pubDate>
      <link>https://forem.com/gurnav224/what-is-internet--5c9i</link>
      <guid>https://forem.com/gurnav224/what-is-internet--5c9i</guid>
      <description>&lt;p&gt;In This blog , I am Writing about What is internet in a very simple way&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi682znvy24rhmsz0sphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi682znvy24rhmsz0sphy.gif" alt="Let's Begin" width="480" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Internet is nothing but a network of wire's connected to each other.&lt;br&gt;
wire are like copper wire , fibre optic and wireless&lt;br&gt;
These wire spread through out the ocean all over the world.&lt;/p&gt;

&lt;p&gt;wire connect's to our computer make's it online and communicate with each other and share our information through these wire &lt;/p&gt;

&lt;p&gt;There are dedicated computer known as server directly connected to the internet 24/7 and store information such as Image, video , document etc &lt;/p&gt;

&lt;p&gt;These computer's/server's having their own unique IP address.&lt;br&gt;
The IP address like home address help them to reach the server.&lt;br&gt;
These IP address looks like 192.168.12. it hard to remember &lt;/p&gt;

&lt;p&gt;so we can associate these number's with name basically Domain Name Server &lt;br&gt;
eg :&lt;br&gt;
goole.com =&amp;gt; 142.250.196.78&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>day 01</title>
      <dc:creator>Gurnav224</dc:creator>
      <pubDate>Fri, 12 Feb 2021 04:09:28 +0000</pubDate>
      <link>https://forem.com/gurnav224/day-01-4kho</link>
      <guid>https://forem.com/gurnav224/day-01-4kho</guid>
      <description>&lt;p&gt;Learning git and GitHub&lt;br&gt;
working my portfolio&lt;/p&gt;

&lt;h1&gt;
  
  
  151days of code
&lt;/h1&gt;

</description>
    </item>
  </channel>
</rss>
