<?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: Nandan Kumar</title>
    <description>The latest articles on DEV Community by Nandan Kumar (@sirius93).</description>
    <link>https://dev.to/sirius93</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%2F175617%2Fffbce4aa-7b34-4bd8-837d-41da6d24ddeb.jpeg</url>
      <title>DEV Community: Nandan Kumar</title>
      <link>https://dev.to/sirius93</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sirius93"/>
    <language>en</language>
    <item>
      <title>Built something over last weekend, thought I will share with my dev community. https://bailoutt.com</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Tue, 23 Sep 2025 16:11:02 +0000</pubDate>
      <link>https://dev.to/sirius93/built-something-over-last-weekend-thought-i-will-share-with-my-dev-community-1aki</link>
      <guid>https://dev.to/sirius93/built-something-over-last-weekend-thought-i-will-share-with-my-dev-community-1aki</guid>
      <description>&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
        &lt;div class="c-embed__cover"&gt;
          &lt;a href="https://bailoutt.com/" class="c-link align-middle" rel="noopener noreferrer"&gt;
            &lt;img alt="" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fframerusercontent.com%2Fassets%2Fbx2KHyDlhJQAxsQUXODShrsUz28.png" height="auto" class="m-0"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="c-embed__body"&gt;
        &lt;h2 class="fs-xl lh-tight"&gt;
          &lt;a href="https://bailoutt.com/" rel="noopener noreferrer" class="c-link"&gt;
            BailOutt |  Escape Awkward Situations | AI Fake Call Service | Social Anxiety Solution
          &lt;/a&gt;
        &lt;/h2&gt;
          &lt;p class="truncate-at-3"&gt;
            Never get trapped in awkward situations again. Get real, believable phone calls from real numbers when you need them most. BailOutt’s AI-powered fake call service helps you escape bad dates, long meetings, and social anxiety with ease.
          &lt;/p&gt;
        &lt;div class="color-secondary fs-s flex items-center"&gt;
            &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fframerusercontent.com%2Fimages%2FR7ZW2oxiKgijD3384CiQcMp0KN4.jpg"&gt;
          bailoutt.com
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>HTML Pitfalls and Gotchas Every Developer Should Avoid</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Fri, 05 Sep 2025 04:23:19 +0000</pubDate>
      <link>https://dev.to/sirius93/html-pitfalls-and-gotchas-every-developer-should-avoid-51em</link>
      <guid>https://dev.to/sirius93/html-pitfalls-and-gotchas-every-developer-should-avoid-51em</guid>
      <description>&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%2F2hwe05rdp4iuytc1xcq5.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%2F2hwe05rdp4iuytc1xcq5.png" alt="HTML pitfalls Banner" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML is easy, said every developer ever.&lt;/p&gt;

&lt;p&gt;HTML is deceptively simple. You open a tag, you close a tag, and something appears on screen. But beneath that simplicity lurk gotchas that can silently break your layout, wreck your SEO, or make your site look unprofessional when shared on social media.&lt;/p&gt;

&lt;p&gt;In this world of frameworks and libraries, its easy to miss some of the basic stuff that needs to be taken care of in your webpage, because your frameworks boilerplate code adds up most of the stuff and takes care of the basics. But its always good to know some of them that are important or arent added by your framework by default.&lt;/p&gt;

&lt;p&gt;Here are the critical HTML pitfalls to avoid and how to fix them immediately.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Forgetting the DOCTYPE Declaration
&lt;/h2&gt;

&lt;p&gt;Skipping the doctype triggers something called as the &lt;strong&gt;quirks mode&lt;/strong&gt; , where browsers start behaving like it's 1999. This results in inconsistent CSS rendering and unpredictable JavaScript behaviour across browsers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Always declare it at the very top of your HTML file:&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;&amp;lt;!DOCTYPE html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Missing the Character Encoding Meta Tag
&lt;/h2&gt;

&lt;p&gt;Without proper character encoding, special characters turn into garbled symbols i.e. (). This breaks accented letters, smart quotes, and emojis, and it makes your webpage content look broken and unprofessional.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Place this inside the&lt;/strong&gt; &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;meta charset="UTF-8"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Forgetting the Viewport Meta Tag
&lt;/h2&gt;

&lt;p&gt;Has it ever happened to you? Your page zooms awkwardly when users double-tap on mobile; Thats because you're missing the viewport meta tag. Without it, your site isn't truly responsive, regardless of your CSS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add this to your&lt;/strong&gt; &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; &lt;strong&gt;section&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;&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Skipping Open Graph Meta Tags
&lt;/h2&gt;

&lt;p&gt;Ever shared your blog on LinkedIn, Twitter, or Facebook only to see a bare URL with no preview card? That's because Open Graph tags are missing. These tags control how your content appears when shared on social media.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add these OG tags for rich sharing previews:&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;&amp;lt;meta property="og:title" content="My Blog Title"&amp;gt;
&amp;lt;meta property="og:description" content="A quick guide to avoiding HTML gotchas."&amp;gt;
&amp;lt;meta property="og:image" content="https://example.com/preview.png"&amp;gt;
&amp;lt;meta property="og:url" content="https://example.com/blog"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pro tip:&lt;/strong&gt; Also consider adding Twitter Card tags for optimal Twitter/X previews.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Ignoring Content Security Policy
&lt;/h2&gt;

&lt;p&gt;Content Security Policy (CSP) helps prevent cross-site scripting (XSS) attacks and other code injection vulnerabilities. It tells browsers which scripts, styles, and resources are allowed to run on your page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Start with a basic CSP meta tag:&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;&amp;lt;meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline';"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This is a starting point. Adjust the policy based on your specific needs and third-party resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Improper Nesting of Elements
&lt;/h2&gt;

&lt;p&gt;Browsers are forgiving, but invalid HTML nesting leads to unpredictable rendering and can break JavaScript that relies on the DOM structure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common nesting mistakes:&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;&amp;lt;!-- Inline elements shouldn't contain block elements --&amp;gt;
&amp;lt;span&amp;gt;&amp;lt;div&amp;gt;Wrong!&amp;lt;/div&amp;gt;&amp;lt;/span&amp;gt;
&amp;lt;!-- Paragraphs can't contain divs --&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;div&amp;gt;Also wrong!&amp;lt;/div&amp;gt;&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Follow these nesting rules:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Inline elements (&lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt;) should &lt;strong&gt;never&lt;/strong&gt; contain block-level elements (&lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; Tags should only wrap inline content, never block-level elements&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When in doubt, check the HTML specification for content models&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;These six HTML gotchas might seem minor, but they're the difference between a professional website and one that breaks in subtle, embarrassing ways. Take five minutes to audit your HTML templatesyour future self (and your users) will thank you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quick checklist for your next project:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;DOCTYPE declaration at the top&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;UTF-8 character encoding&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Viewport meta tag for mobile&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open Graph tags for social sharing&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Basic Content Security Policy&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Valid HTML nesting&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember: browsers are forgiving, but that doesn't mean we should be sloppy. Clean HTML is the foundation of a reliable web experience.&lt;/p&gt;

&lt;p&gt;Thats all, folks! I hope you found this helpful. If you enjoyed this, check out more articles on my Blog, &lt;a href="https://blog.nandan.dev/" rel="noopener noreferrer"&gt;https://blog.nandan.dev/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to comment, email me at &lt;a href="http://mailto:connect@nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;connect@nandan.dev&lt;/strong&gt;&lt;/a&gt;, or connect with me on Twitter, Instagram, or GitHub. Dont forget to subscribe to my newsletter for regular updates on JavaScript topics!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/_sirius93_" rel="noopener noreferrer"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://www.instagram.com/nandandotdev" rel="noopener noreferrer"&gt;&lt;strong&gt;Instagram&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://github.com/sirius93" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;Website&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>metatags</category>
      <category>gotchas</category>
    </item>
    <item>
      <title>Accessibility in Front End Development</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Sat, 09 Aug 2025 16:57:50 +0000</pubDate>
      <link>https://dev.to/sirius93/accessibility-in-front-end-development-3l9i</link>
      <guid>https://dev.to/sirius93/accessibility-in-front-end-development-3l9i</guid>
      <description>&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%2Fq08tgra31o0z10u8zsr5.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%2Fq08tgra31o0z10u8zsr5.png" alt="a11y Heading image" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me start with this: Accessibility is not a buzzword; its a crucial feature that every web application should have.&lt;/p&gt;

&lt;p&gt;It should not be mandated by the government, but rather it should be taken as the responsibility of every developer to make their websites accessible to all users.&lt;/p&gt;

&lt;p&gt;Making a website accessible will not just help you avoid government penalties, it will also give you a wider user base. Accessibility is all about making your website accessible to everyone.&lt;/p&gt;

&lt;p&gt;On that note, lets get this blog started -&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Accessibility
&lt;/h2&gt;

&lt;p&gt;Accessibility is ensuring that your web application is usable by people with disabilities, including people with&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Visual impairment (Blindness, Colour Blindness) -&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Hearing loss&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Motor Impairment ( Difficulty using the mouse)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cognitive limitation (Dyslexia, Attention Disorder)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Accessibility Core Principle (POUR)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Principle&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;P&lt;/strong&gt;erceivable&lt;/td&gt;
&lt;td&gt;Content must be perceivable by all (e.g., alt text, captions)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;O&lt;/strong&gt;perable&lt;/td&gt;
&lt;td&gt;All functionality must work via keyboard or assistive devices&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;U&lt;/strong&gt;nderstandable&lt;/td&gt;
&lt;td&gt;Content should be readable and predictable&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;R&lt;/strong&gt;obust&lt;/td&gt;
&lt;td&gt;Must work with various assistive technologies&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How can people with disabilities use the applications
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Accessibility Need&lt;/th&gt;
&lt;th&gt;Requirement / Support&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Visual Impairment&lt;/td&gt;
&lt;td&gt;Should be usable with screen readers, VoiceOver, and font scaling support&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hearing Loss&lt;/td&gt;
&lt;td&gt;Closed captions for video and audio&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Motor Impairment&lt;/td&gt;
&lt;td&gt;Keyboard accessibility support&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cognitive Limitation&lt;/td&gt;
&lt;td&gt;Simple language&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Accessibility Standards
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Web Content Accessibility Guidelines (WCAG)
&lt;/h3&gt;

&lt;p&gt;Defines Accessibility levels as &lt;strong&gt;A&lt;/strong&gt; , &lt;strong&gt;AA&lt;/strong&gt; &amp;amp; &lt;strong&gt;AAA&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Read More: &lt;a href="https://www.w3.org/WAI/standards-guidelines/wcag/" rel="noopener noreferrer"&gt;https://www.w3.org/WAI/standards-guidelines/wcag/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Accessible Rich Internet Applications (ARIA)&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Adds accessibility support to non-semantic elements.&lt;/p&gt;

&lt;p&gt;Read More: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Americans with Disabilities Act (ADA)
&lt;/h3&gt;

&lt;p&gt;Legal mandate in the US for accessible digital content&lt;/p&gt;

&lt;p&gt;Read More: &lt;a href="https://www.ada.gov/" rel="noopener noreferrer"&gt;https://www.ada.gov/&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;AA&lt;/strong&gt; is the most commonly required level of compliance.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How to make a web application Accessible
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Use Semantic Tags
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use tags like &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; , &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt; etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Avoid using div and span all over your application&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Support Keyboard Accessibility
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Actions should be usable via. keyboard, including opening modals, dropdowns, and toasts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;code&gt;tabindex&lt;/code&gt; to align focus correctly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use focus, keydown event listeners correctly&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Use Aria Roles when needed
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use aria-label, aria-hidden, role="dialog", etc., when native semantics are not sufficient&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://w3c.github.io/aria/" rel="noopener noreferrer"&gt;https://w3c.github.io/aria/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Focus Management
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Trap focus in modals&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Restore focus when modals close&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Visibly indicate focus using focus-visible or outline&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Maintain Colour Contrast
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;4.5: 1 for normal text in &lt;strong&gt;AA&lt;/strong&gt; Standard&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;7:2 for &lt;strong&gt;AAA&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check contrast: &lt;a href="https://webaim.org/resources/contrastchecker/" rel="noopener noreferrer"&gt;https://webaim.org/resources/contrastchecker/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Using Images and Other Media
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Use alt text for images&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add transcripts/captions for videos/audio&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Avoid autoplaying media files. i.e. Video&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tools for Accessibility Testing
&lt;/h2&gt;

&lt;p&gt;The tools listed below are some of the most common tools for testing accessibility in a web application.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;Use Case&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;axe DevTools&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Chrome extension to audit a11y&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Lighthouse&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Built-in browser audits&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;NVDA / VoiceOver&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Screen reader testing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Tab key&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Test keyboard navigation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;WCAG &lt;strong&gt;AAA is harder to implement, and most website are expected to maintain AA compliant.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I hope by the end of this post, you have a good idea of why accessibility is important and how you can add accessibility support to your application.&lt;/p&gt;

&lt;p&gt;Thats all, folks! I hope you found this helpful. If you enjoyed this, check out more articles on my Blog, &lt;a href="https://blog.nandan.dev/" rel="noopener noreferrer"&gt;https://blog.nandan.dev/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to comment, email me at &lt;a href="http://mailto:connect@nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;connect@nandan.dev&lt;/strong&gt;&lt;/a&gt;, or connect with me on Twitter, Instagram, or GitHub. Dont forget to subscribe to my newsletter for regular updates on JavaScript topics!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/_sirius93_" rel="noopener noreferrer"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://www.instagram.com/nandandotdev" rel="noopener noreferrer"&gt;&lt;strong&gt;Instagram&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://github.com/sirius93" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;Website&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>frontend</category>
      <category>aria</category>
    </item>
    <item>
      <title>Instagram Front-End System Design</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Fri, 01 Aug 2025 05:19:41 +0000</pubDate>
      <link>https://dev.to/sirius93/instagram-front-end-system-design-4fd6</link>
      <guid>https://dev.to/sirius93/instagram-front-end-system-design-4fd6</guid>
      <description>&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%2F3t9m7sc2pdmcuvyx7qbt.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%2F3t9m7sc2pdmcuvyx7qbt.png" alt="Banner" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me start by putting one thing forward: System design is not about writing a memorised answer on paper. Its more about thinking, planning and strategising.&lt;/p&gt;

&lt;p&gt;Hence, there is no correct answer, but a correct Framework. Understanding and approaching system design with the RADIO &lt;strong&gt;RADIO framework&lt;/strong&gt; (Requirements, Architecture, Design, Implementation, Optimisation) helps you streamline your answer.&lt;/p&gt;

&lt;p&gt;Additionally, you can treat this blog as a framework for everything that requires building a feed, i.e. Twitter, Facebook, or Orkut, for that matter.&lt;/p&gt;

&lt;p&gt;But everything beyond that is dependent on your knowledge and understanding of the system.&lt;/p&gt;

&lt;p&gt;Designing a platform like Instagram might sound overwhelming at first, but breaking it down using the &lt;strong&gt;RADIO framework&lt;/strong&gt; (Requirements, Architecture, Design, Implementation, Optimisation) makes it manageable and actually kinda fun. I recently took a shot at this, and here's what I came up with, plus a few tweaks and lessons learned along the way.&lt;/p&gt;




&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔧 Functional Requirements:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;News Feed that shows text, images, and videos&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;User info (photo, username) on each post&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Like, comment, and share buttons&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pagination or infinite scroll&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lazy loading for media&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🚫 Non-Functional Requirements:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fully responsive (mobile + desktop)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Accessibility compliant&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Optimised for performance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports A/B testing for features&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Localisation and translation support&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bonus points if it supports offline mode and has a fallback UI.&lt;/p&gt;




&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;Start by defining your core building blocks:&lt;/p&gt;

&lt;h3&gt;
  
  
  📂 Components:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PostCard
├── TextContent
├── ImageGallery / VideoPlayer
├── UserHeader (avatar + name)
├── PostActions (like/comment/share)

Feed
└── PostCard[]

CommentSection
LikeButton
ShareButton

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

&lt;/div&gt;



&lt;p&gt;Each of these is reusable and maintainable the key to scalable front-end architecture.&lt;/p&gt;




&lt;h2&gt;
  
  
  Design
&lt;/h2&gt;

&lt;p&gt;Keep your data models clean and normalised. Here's what worked well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Post = {
  id: string;
  text?: string;
  images?: string[];
  video?: string;
  userId: string;
  comments: Comment[];
  likes: Like[];
  createdAt: string;
};

type User = {
  id: string;
  name: string;
  username: string;
  avatar: string;
  postIds: string[];
};

type Like = {
  userId: string;
  postId: string;
};

type Comment = {
  id: string;
  userId: string;
  postId: string;
  text: string;
  createdAt: string;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Avoid embedding full &lt;code&gt;User&lt;/code&gt; objects inside posts&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use IDs to reference everything&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Support multiple images per post (carousel style)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;p&gt;Here's how the main flow looks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Feed Page&lt;/strong&gt; : loads posts using a custom hook (&lt;code&gt;useFetchPosts&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Loop through &lt;code&gt;PostCard&lt;/code&gt; components to render UI&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use libraries like React Query or SWR for cache + fetch&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Defer comment loading until user clicks "View all comments"&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Suggested folder structure:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/components
  /Post
    PostCard.tsx
    PostMedia.tsx
    PostFooter.tsx
  /User
  /Comment
/hooks
  useFetchPosts.ts
/pages
  index.tsx // News Feed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Optimization
&lt;/h2&gt;

&lt;p&gt;Performance matters more than ever. Here's what to prioritise:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;📸 Lazy load images and videos&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🔄 Use &lt;code&gt;IntersectionObserver&lt;/code&gt; for infinite scroll&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🏔 PWA support (with service workers)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;📑 Bundle splitting + code-splitting&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🚀 Skeleton loaders while fetching&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🌍 Localised text using &lt;code&gt;react-i18next&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;📉 Memoise unchanging components with &lt;code&gt;React.memo&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Designing Instagram from the front-end isnt about copying their UI; it's about building a thoughtful system that can scale, perform, and feel native on any device. Use the RADIO framework to break down the chaos into manageable parts, and you'll be surprised how fast it comes together.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Polyfills of JS Array Methods - Flat, Map, Filter &amp; Reduce</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Tue, 13 May 2025 14:03:11 +0000</pubDate>
      <link>https://dev.to/sirius93/polyfills-of-js-array-methods-flat-map-filter-reduce-1165</link>
      <guid>https://dev.to/sirius93/polyfills-of-js-array-methods-flat-map-filter-reduce-1165</guid>
      <description>&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%2F2l51sgxmabzt3rhvdasj.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%2F2l51sgxmabzt3rhvdasj.png" alt="Array polyfills - Banner Image" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alright, confession time, Ive been writing JavaScript for a while now, but theres something oddly satisfying about going back to the basics. You know, like trying to bake your bread from scratch even though you live next to a bakery. Thats exactly what this post is about: baking our versions of some classic array methods.&lt;/p&gt;

&lt;p&gt;Want to understand what polyfills are? &lt;a href="https://dev.to/sirius93/polyfills-for-call-apply-and-bind-lets-build-them-from-scratch-15g7"&gt;I have covered them in my blog Polyfills for Call, Apply &amp;amp; Bind.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Why? Because it's fun. Because it's educational. And because the next time someone throws a technical interview curveball at you, like "Can you write your own &lt;code&gt;reduce&lt;/code&gt;" and youll casually say, "Sure, do you want it with comments or without?"&lt;/p&gt;

&lt;p&gt;Today, were building polyfills for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;flat()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;map()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;filter()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;reduce()&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lets roll.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;flat()&lt;/code&gt; A Pancake Stack for Arrays
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(!Array.prototype.myFlat){
    Array.prototype.myFlat = function(depth){
        if(depth &amp;lt; 0) return this;

        const flatten = function(arr, depth){
            return arr.reduce((acc,ele)=&amp;gt;{
                if(Array.isArray(ele) &amp;amp;&amp;amp; depth &amp;gt; 0){
                    acc = acc.concat(flatten(ele,depth -1));
                }else{
                    acc.push(ele);
                }
                return acc;
            },[])
        }

        return flatten(this,depth);
    }
}

const nestedArray = [1, [2, [3, [4, 5]]], 6];

console.log(nestedArray.myFlat()); // Default depth = 1 =&amp;gt; [1, 2, [3, [4, 5]], 6]
console.log(nestedArray.myFlat(2)); // Depth = 2 =&amp;gt; [1, 2, 3, [4, 5], 6]
console.log(nestedArray.myFlat(3)); // Depth = 3 =&amp;gt; [1, 2, 3, 4, 5, 6]
console.log(nestedArray.myFlat(0)); // Depth = 0 =&amp;gt; [1, [2, [3, [4, 5]]], 6]

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

&lt;/div&gt;



&lt;p&gt;Just a basic flattening function. Will it replace your backend job? No. But will it make you feel cool? Absolutely.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;map()&lt;/code&gt; Because Sometimes Arrays Need a Makeover
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(!Array.prototype.myMap){
    Array.prototype.myMap = function(fn, thisArg){
       if(this == null)  { return new Error("Not an array")};

       if(typeof(fn) != 'function') {return new Error("Not an array")}

       let result = [];

       for(let i=0; i&amp;lt; this.length; i++){
           if(i in this){
               result.push(fn.call(thisArg,this[i], i, this));
           }
       }
       return result;
    }
}

a = [1,2,3,4,5].myMap(function (mem) {
    return mem*mem;
})

console.log(a); // [ 1, 4, 9, 16, 25 ]

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

&lt;/div&gt;



&lt;p&gt;Simple and clean. No magical spells involved.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;filter()&lt;/code&gt; Only the Worthy Shall Pass
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(!Array.prototype.myFilter){
    Array.prototype.myFilter = function(fn, thisArg){
       if(this == null)  { return new Error("Not an array")};

       if(typeof(fn) != 'function') {return new Error("Not an array")}

       let result = [];

       for(let i=0; i&amp;lt; this.length; i++){
           if(i in this &amp;amp;&amp;amp; fn.call(thisArg,this[i], i, this)){
               result.push(this[i]);
           }
       }
       return result;
    }
}

b = [1,2,3,4,5].myFilter(function (mem) {
    return mem &amp;gt; 1;
})

console.log(b) //[ 2, 3, 4, 5 ]

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

&lt;/div&gt;



&lt;p&gt;Give it a test run with your own weird conditions. Even filter out people who don't like coffee; your call.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;reduce()&lt;/code&gt; The Boss Level
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(!Array.prototype.myReduce){
    Array.prototype.myReduce = function(callback,initialValue){
        if(this == null) {return new Error("Not an Array");}

        if(typeof(callback) != 'function') {
            return new Error("Not a function");
        }

        let arr = this;
        let len = arr.length;

        let hasInitial = arguments.length &amp;gt; 1;
        let accumulator = hasInitial ? initialValue : arr[0];
        let startIndex = hasInitial ? 0 : 1;

        if (len === 0 &amp;amp;&amp;amp; !hasInitial) {
          throw new Error("Reduce of empty array with no initial value");
        }


        for (let i = startIndex; i &amp;lt; len; i++) {
          if (i in arr) {
            accumulator = callback(accumulator, arr[i], i, arr);
          }
        }

        return accumulator;
    }
}

let a = [1, 2, 3].myReduce((acc, val) =&amp;gt; acc + val, 0);
console.log(a);

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

&lt;/div&gt;



&lt;p&gt;Reduce is like that friend who seems intimidating at first, but once you get to know them, they carry the whole squad.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Do This?
&lt;/h3&gt;

&lt;p&gt;You may never need to use these in a production app. But knowing how they work helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Understand JavaScript fundamentals better.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Appreciate the built-in methods more.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Have something cool to say in interviews or while pretending to debug in coffee shops.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So go ahead, mess around with these, add your own flavour, and maybe even extend a couple more methods just for fun.&lt;/p&gt;

&lt;p&gt;Thats all, folks! I hope you found this helpful. If you enjoyed this, check out more articles on my Blog, &lt;a href="https://blog.nandan.dev/" rel="noopener noreferrer"&gt;https://blog.nandan.dev/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to comment, email me at &lt;a href="http://mailto:connect@nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;connect@nandan.dev&lt;/strong&gt;&lt;/a&gt;, or connect with me on Twitter, Instagram, or GitHub. Dont forget to subscribe to my newsletter for regular updates on JavaScript topics!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/_sirius93_" rel="noopener noreferrer"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://www.instagram.com/nandandotdev" rel="noopener noreferrer"&gt;&lt;strong&gt;Instagram&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://github.com/sirius93" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;Website&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>polyfills</category>
      <category>arraymethods</category>
      <category>javascript</category>
      <category>arrays</category>
    </item>
    <item>
      <title>Polyfills for Call, Apply, and Bind — Let’s Build Them From Scratch</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Mon, 28 Apr 2025 16:51:28 +0000</pubDate>
      <link>https://dev.to/sirius93/polyfills-for-call-apply-and-bind-lets-build-them-from-scratch-15g7</link>
      <guid>https://dev.to/sirius93/polyfills-for-call-apply-and-bind-lets-build-them-from-scratch-15g7</guid>
      <description>&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%2Fisivduca05yae78s5phy.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%2Fisivduca05yae78s5phy.png" alt="Plyfill call,Apply,Bind Cover" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Okay, so if you have ever deep-dived into JavaScript interviews or just casually scrolled through dev Twitter (yes, thats a thing), you would have stumbled upon someone throwing around the words &lt;strong&gt;polyfill&lt;/strong&gt; like they were born building web browsers.&lt;/p&gt;

&lt;p&gt;And if youre like me, you probably nodded along, opened a tab to Google it later, and procrastinated.&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%2Fk9ctqdqoegm6l9nqr9z0.gif" 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%2Fk9ctqdqoegm6l9nqr9z0.gif" alt="Procastination Gif" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But no worries. Youre here now, and we are going to figure this out &lt;em&gt;together.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;First things first What the heck is a polyfill?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;polyfill&lt;/strong&gt; is just a piece of code (usually JavaScript) that &lt;strong&gt;adds functionality to older browsers&lt;/strong&gt; that do not natively support a certain feature.&lt;/p&gt;

&lt;p&gt;Think of it like you bringing a power bank to an event where there are no charging points. Your phone is old? No problem. You got the backup.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Now Why Call, Apply, and Bind?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Because theyre like the Avengers of function manipulation in JavaScript.&lt;/p&gt;

&lt;p&gt;And also because they confuse almost everyone at first.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;call&lt;/code&gt; lets you call a function with a given this value and arguments.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;apply&lt;/code&gt; is like &lt;code&gt;call&lt;/code&gt;, but arguments are passed as an array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;bind&lt;/code&gt; doesnt immediately invoke the function. It &lt;em&gt;returns a new function&lt;/em&gt; with a given this.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://dev.to/sirius93/yet-another-blog-on-call-apply-bind-336d"&gt;Here is a detailed write-up on call, apply &amp;amp; bind&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Simple enough, right? Now lets make our versions&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Polyfill for call&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Heres how we can build a &lt;strong&gt;polyfill for call&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;Function.prototype.myCall = function(context,...args){ 
    context = context || globalThis;
    let Symbolfn = Symbol("fn"); // Unique key
    context[Symbolfn] = this; // Assign 'this' function to the context
    let result = context[Symbolfn](...args); // Call the function
    delete context[Symbolfn];  // Clean up
    return result;
}

// Usage
function sayHello(greeting) {
  console.log(`${greeting}, ${this.name}`);
}

const user = { name: "Nandan" };
sayHello.myCall(user, "Hello");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cool, right? Not rocket science.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Polyfill for apply&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now, lets tweak it a bit for &lt;strong&gt;apply&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;Function.prototype.myApply = function(context,args){
    context = context || globalThis;
    let Symbolfn = Symbol("fn");
    context[Symbolfn] = this;
    let result = args ? context[Symbolfn](...args) : context[Symbolfn]();
    delete context[Symbolfn];
    return result;
}

// Usage
sayHello.myApply(user, ["Hi"]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Polyfill for bind&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now comes the big boss &lt;strong&gt;bind&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;Function.prototype.myBind = function(context,...initialArgs){
    let fn = this;
    return function(...functArgs){
        return fn.apply(context, [...initialArgs,...functArgs])
    }
}

// Usage
const boundSayHello = sayHello.myBind(user, "Hey");
boundSayHello(); // Outputs: Hey, Nandan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;bind doesnt call the function right away.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It returns a &lt;em&gt;new function&lt;/em&gt; that you can call later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We merge the arguments provided at bind-time and call-time.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Thats it You just built call, apply, and bind polyfills!&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Honestly, when I first read about polyfills, I thought it was some deep internal browser magic. Turns out, its just about creatively manipulating JavaScripts behavior.&lt;/p&gt;

&lt;p&gt;If you take one thing from this post, let it be this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The cowards never started and the weak died along the way. That leaves us, ladies and gentlemen. Us.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;(Yeah, thats a quote from &lt;em&gt;Shoe Dog&lt;/em&gt;. Still fits perfectly here, doesnt it?)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://kitaaben.com/p/just-do-it-the-real-story-behind-nike-s-rise" rel="noopener noreferrer"&gt;Heres one if you want to read a review of the book Shoe Dog, written by me.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thats all, folks! I hope you found this short note on Polyfills of Call, Apply &amp;amp; Bind helpful. If you enjoyed this, check out more articles on my Blog, &lt;a href="https://blog.nandan.dev/" rel="noopener noreferrer"&gt;https://blog.nandan.dev/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to comment, email me at &lt;a href="http://mailto:connect@nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;connect@nandan.dev&lt;/strong&gt;&lt;/a&gt;, or connect with me on Twitter, Instagram, or GitHub. Dont forget to subscribe to my newsletter for regular updates on JavaScript topics!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/_sirius93_" rel="noopener noreferrer"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://www.instagram.com/nandandotdev" rel="noopener noreferrer"&gt;&lt;strong&gt;Instagram&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://github.com/sirius93" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;Website&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>polyfills</category>
      <category>callapplyandbindmeth</category>
      <category>interviewquestions</category>
    </item>
    <item>
      <title>I Vibe Coded an AI Book Recommendation App and was DDOS-ed for it.</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Tue, 15 Apr 2025 10:37:13 +0000</pubDate>
      <link>https://dev.to/sirius93/i-built-an-ai-book-recommendation-app-and-was-ddos-ed-for-it-p8</link>
      <guid>https://dev.to/sirius93/i-built-an-ai-book-recommendation-app-and-was-ddos-ed-for-it-p8</guid>
      <description>&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%2Fiecltirwrolay72b2vk5.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%2Fiecltirwrolay72b2vk5.png" alt="built an AI Book Recommendation App and was DDOS-ed" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Last week, Google introduced its AI copilot Firebase Studio, and I decided to give it a try. It got me thinking about what I want to do next.&lt;/p&gt;

&lt;p&gt;If you may be following me on socials, I just started a newsletter for book reviews &amp;amp; suggestions. Check &lt;a href="https://kitaaben.com" rel="noopener noreferrer"&gt;https://kitaaben.com&lt;/a&gt;. That got me thinking: What if I built a small book recommendation application that can help users get book recommendations based on their interests?&lt;/p&gt;

&lt;p&gt;I started building it on Firebase studio. Started with a simple prompt to build an AI-based book recommendation application that shows a good variety of genres by default and an interest field for additional context. The Number of books you want to be recommended is either 1/3/6 or 12.&lt;/p&gt;

&lt;p&gt;The initial version came with these fields. But after some iterations, I decided to add the email field and email integration to help users get the recommendation directly to their email.&lt;/p&gt;

&lt;p&gt;The tech stack looks something like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Nextjs + Reactjs ( For the application)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Gemini API (For AI)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Firebase (For Hosting)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Resend (For Email - Free Tier)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The final version looked like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bookwise.kitaaben.com/" rel="noopener noreferrer"&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%2Fl488giekwyxolt91pyfg.png" alt="Bookwise AI Landing Page" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After some testing and a lot of dopamine, I went ahead and made it public. Mapped it to a subdomain and made it public. Here is the URL if you want to give it a try: &lt;a href="https://bookwise.kitaaben.com/" rel="noopener noreferrer"&gt;https://bookwise.kitaaben.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I shared it in my friends WhatsApp group, Instagram, Twitter( now X), Linkedin almost everywhere I could.&lt;/p&gt;

&lt;p&gt;But seems like someone didnt like the spamming and decided to do something about it. By launching a DDOS attack on my website.Targeting my email functionality, trying to exhaust my email limit and increasing my cloud hosting + AI usage cost.&lt;/p&gt;

&lt;p&gt;See the sudden spike in the requests?&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%2Fbdwnpki575objsxzxjhc.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%2Fbdwnpki575objsxzxjhc.png" alt="Bookwise AI backend dashboard" width="800" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Panic set in; I didnt know what to do. Should I bring down the site and end this or something else? I decided not to give up and just think and act quickly&lt;/p&gt;

&lt;p&gt;I did and quickly signed up for Cloudflare, added the Cloudflare protection layer to my app and observed the behaviour for some time. By this time, my email limit of 200 emails by resend had already been exhausted, so I waited for the next day and added a caching layer to store the emails and rate limit the emails to 3 emails per hour.&lt;/p&gt;

&lt;p&gt;Things seem to be stable for now. The traffic has dropped as well. However, I would not mind some humans trying the app, benefiting from it and providing some real feedback.&lt;/p&gt;

&lt;p&gt;If you are a human reading this, give the app a try. Tell me what you like/dislike. I am always just an email away at &lt;a href="//mailto:connect@nandan.dev"&gt;connect@nandan.dev&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Thats all, folks! I hope you found this short note on Call, Apply &amp;amp; Bind helpful. If you enjoyed this, check out more articles on my website, &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;https://nandan.dev/&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to comment, email me at &lt;a href="http://mailto:connect@nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;connect@nandan.dev&lt;/strong&gt;&lt;/a&gt;, or connect with me on Twitter, Instagram, or GitHub. Dont forget to subscribe to my newsletter for regular updates on JavaScript topics!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/_sirius93_" rel="noopener noreferrer"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://www.instagram.com/nandandotdev" rel="noopener noreferrer"&gt;&lt;strong&gt;Instagram&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://github.com/sirius93" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;Website&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>vibecoding</category>
      <category>ddos</category>
      <category>ddosprotection</category>
    </item>
    <item>
      <title>Yet another blog on Call, Apply &amp; Bind..!!</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Fri, 22 Nov 2024 11:05:15 +0000</pubDate>
      <link>https://dev.to/sirius93/yet-another-blog-on-call-apply-bind-336d</link>
      <guid>https://dev.to/sirius93/yet-another-blog-on-call-apply-bind-336d</guid>
      <description>&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%2Fzjvysbp8rmoc9wyxbwgy.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%2Fzjvysbp8rmoc9wyxbwgy.png" alt="Call bind apply" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
Bla Bla Bla..&lt;/p&gt;

&lt;p&gt;Okay, Hear me out..!!&lt;/p&gt;

&lt;p&gt;Hundreds of blogs and tutorials explain call, bind, and apply. Heck, even ChatGPT and Copilot can simplify them for you!&lt;/p&gt;

&lt;p&gt;So why another post? Well, this ones not for _you_its my self-note as I revisit JavaScript fundamentals.&lt;/p&gt;

&lt;p&gt;Even after 8 years in front-end development, I sometimes mix up these methods. Turns out, the confusion often stems from how theyre grouped in interview questions. Let me break it down for youthis time, in a way that sticks.&lt;/p&gt;
&lt;h2&gt;
  
  
  Can we skip to the good part.
&lt;/h2&gt;

&lt;p&gt;Why is it always call, bind, and apply in interviews? Functionally, call and apply are closerthey invoke the function immediatelywhile bind returns a new function. Thats why Ive grouped them this way in the title.&lt;/p&gt;

&lt;p&gt;Let's look at their usage to understand it better.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is common among Call, Bind &amp;amp; Apply?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;call&lt;/strong&gt; , &lt;strong&gt;bind&lt;/strong&gt; , and &lt;strong&gt;apply&lt;/strong&gt; are methods available on functions that allow you to explicitly set the value of &lt;strong&gt;this&lt;/strong&gt; and pass arguments to the function.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is the difference between Call, Bind &amp;amp; Apply?
&lt;/h3&gt;

&lt;p&gt;While Call and Apply Immediately invoke the function, the Bind method does not immediately invoke the function. instead, it returns a new function with &lt;strong&gt;this&lt;/strong&gt; set to a specified value, and this returned function can be invoked/executed later.&lt;/p&gt;
&lt;h3&gt;
  
  
  What is the difference between Call and Apply then?
&lt;/h3&gt;

&lt;p&gt;While both Call and Apply immediately invoke the function with the custom this, its how they take the additional argument that differentiates them.&lt;/p&gt;

&lt;p&gt;While Call takes the individual arguments, Apply takes an array of arguments.&lt;/p&gt;
&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;p&gt;Lets look at the below argument to understand the use of call, apply and bind.&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;Greetings&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;greeting&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;punctuation&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;greeting&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="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; &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;punctuation&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="kd"&gt;var&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;Nandan&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Call: Immediately invokes the function with individual arguments&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;Greetings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&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="s2"&gt;Hello&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;!&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 : Hello Nandan !&lt;/span&gt;

&lt;span class="c1"&gt;// Apply: Immediately invokes the function, but takes arguments as an array&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;Greetings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply&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="s2"&gt;Hello&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;!&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 : Hello Nandan !&lt;/span&gt;

&lt;span class="c1"&gt;// Bind: Returns a new function with `this` bound to the specified value&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Greetings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&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="s2"&gt;Hello&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;!&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="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt; &lt;span class="c1"&gt;// Output : Hello Nandan !&lt;/span&gt;

&lt;span class="c1"&gt;//Note:&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;Greetings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&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="s2"&gt;Hello&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;!&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 : It will return a function&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Some Additional Examples
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Using&lt;/strong&gt; call &lt;strong&gt;:&lt;/strong&gt; Borrowing methods from another object:&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;person1&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;Nandan&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;person2&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;Kumar&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;introduce&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="s2"&gt;`Hi, 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;`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;introduce&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Hi, my name is Nandan&lt;/span&gt;
&lt;span class="nx"&gt;introduce&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Hi, my name is Kumar&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using&lt;/strong&gt; apply &lt;strong&gt;:&lt;/strong&gt; Finding the max value in an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nx"&gt;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="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;max&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Using&lt;/strong&gt; bind &lt;strong&gt;:&lt;/strong&gt; Event handling with custom this:&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;button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;myButton&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;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;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;Nandan&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;greet&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="s2"&gt;`Hello, &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;`&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;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Additionally, I hope this table will help you understand it better.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Feature&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Execution&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Arguments&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;Use Case&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;call&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Executes the function immediately&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Passed individually&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;When you know arguments at call time&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;apply&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Executes the function immediately&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Passed as an array&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;When arguments are in an array&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;&lt;strong&gt;bind&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Returns a new function (does not execute)&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;Optionally pre-filled for the new function&lt;/p&gt;&lt;/td&gt;
&lt;td colspan="1" rowspan="1"&gt;&lt;p&gt;When you need a reusable or pre-configured function&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Thats all, folks! I hope you found this short note on Call, Apply &amp;amp; Bind helpful. If you enjoyed this, check out more articles on my website, &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;https://nandan.dev/&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to comment, email me at &lt;a href="http://mailto:connect@nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;connect@nandan.dev&lt;/strong&gt;&lt;/a&gt;, or connect with me on Twitter, Instagram, or GitHub. Dont forget to subscribe to my newsletter for regular updates on JavaScript topics!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/_sirius93_" rel="noopener noreferrer"&gt;&lt;strong&gt;Twitter&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://www.instagram.com/nandandotdev" rel="noopener noreferrer"&gt;&lt;strong&gt;Instagram&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://github.com/sirius93" rel="noopener noreferrer"&gt;&lt;strong&gt;Github&lt;/strong&gt;&lt;/a&gt; | &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;Website&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>learning</category>
      <category>thiskeyword</category>
      <category>objects</category>
    </item>
    <item>
      <title>What are Javascript Closures?</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Mon, 18 Nov 2024 17:04:39 +0000</pubDate>
      <link>https://dev.to/sirius93/what-are-javascript-closures-1mgi</link>
      <guid>https://dev.to/sirius93/what-are-javascript-closures-1mgi</guid>
      <description>&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%2Fsa9wv5p0gch7cmpx4ge7.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%2Fsa9wv5p0gch7cmpx4ge7.png" alt="Javascript Closures" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Closures are a fundamental concept in JavaScript that enables powerful features like data privacy, state persistence, and functional programming. This blog will demystify closures with examples and practical use cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  When are closures created?
&lt;/h2&gt;

&lt;p&gt;Closures are created when a function &lt;strong&gt;(inner function)&lt;/strong&gt; is defined inside another function &lt;strong&gt;(outer function).&lt;/strong&gt; The inner function has access to the outer function's lexical scope &lt;strong&gt;(variables)&lt;/strong&gt; even after the outer function is executed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lexical Scope in Javascript
&lt;/h3&gt;

&lt;p&gt;Lexical scope means a functions scope is determined by where it is written in the code, not where it is executed. This allows inner functions to access variables from their outer functions even if the outer function has already finished executing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Usage
&lt;/h3&gt;

&lt;p&gt;Closures are used for creating Private variables and persistent States (Cache, Memoisation etc.).&lt;/p&gt;

&lt;h3&gt;
  
  
  Closures with Examples
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;A Simple counter&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;function Outer() {
    let count = 0; // count is a private variable
    return function inner() {
        count++; // count is updated every time inner is called
        return count; // the updated value of count is returned
    };
}

let Counter = Outer(); 
Counter(); // 1 (count starts at 0, incremented to 1)
Counter(); // 2 (incremented again)
Counter(); // 3

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Building a cache leveraging closure&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;function ObjectCache() {
    let Obj = {}; // Obj acts as a private cache
    return function ObjectUpdate(key, value) {
        if (!Obj[key]) {
            Obj[key] = value; // Add key-value to cache if not already present
            return Obj; // Return updated cache
        } else {
            return new Error("Duplicate Key"); // Prevent overwriting
        }
    };
}

let cache = ObjectCache();
cache("a", "b"); // {a: 'b'}
cache("a", "c"); // Error: Duplicate Key
cache("alpha", "romeo"); // {a: 'b', alpha: 'romeo'}

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Real World Examples
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Event Listeners - Click Counter&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;function attachListener(element) {
    let count = 0;
    element.addEventListener('click', () =&amp;gt; {
        count++;
        console.log(`Clicked ${count} times`);
    });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;A Better Counter&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;const CounterModule = (() =&amp;gt; {
    let count = 0;
    return {
        increment: () =&amp;gt; ++count,
        reset: () =&amp;gt; (count = 0),
        decrement: () =&amp;gt; --count
    };
})();

CounterModule.increment(); // 1
CounterModule.increment(); // 2
CounterModule.decrement(); // 1
CounterModule.reset(); // 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thats all, folks! I hope you found this short blog on closures helpful. If you enjoyed this, check out more articles on my website, &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;https://nandan.dev/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to comment, email me at &lt;a href="http://mailto:connect@nandan.dev" rel="noopener noreferrer"&gt;connect@nandan.dev&lt;/a&gt;, or connect with me on Twitter, Instagram, or GitHub. Dont forget to subscribe to my newsletter for regular updates on JavaScript topics!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/_sirius93_" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; | &lt;a href="https://www.instagram.com/nandandotdev" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; | &lt;a href="https://github.com/sirius93" rel="noopener noreferrer"&gt;Github&lt;/a&gt; | &lt;a href="https://nandan.dev" rel="noopener noreferrer"&gt;Website&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>closuresinjavascript</category>
      <category>lexicalscope</category>
      <category>interviewquestions</category>
    </item>
    <item>
      <title>System Design: SQL vs NoSQL databases and what distinguishes them.</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Tue, 22 Oct 2024 09:19:51 +0000</pubDate>
      <link>https://dev.to/sirius93/system-design-sql-vs-nosql-databases-and-what-distinguishes-them-5ai3</link>
      <guid>https://dev.to/sirius93/system-design-sql-vs-nosql-databases-and-what-distinguishes-them-5ai3</guid>
      <description>&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%2Fd2q7d02j9zn4ji2x2foa.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%2Fd2q7d02j9zn4ji2x2foa.png" alt="System Design:SQL VS NOSQL" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the realm of databases, two primary types of solutions exist, SQL (relational) and NoSQL (non-relational) databases. These two categories differ significantly in their construction, the nature of the data they store, and their storage methods. Relational databases are structured with predefined schemas, while non-relational databases are unstructured, distributed, and feature dynamic schemas.&lt;/p&gt;

&lt;h2&gt;
  
  
  High-level differences
&lt;/h2&gt;

&lt;p&gt;Here are some high-level differences between SQL and NoSQL:&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage
&lt;/h3&gt;

&lt;p&gt;SQL stores data in tables where each row represents an entity, and each column represents a data point related to that entity.&lt;/p&gt;

&lt;p&gt;NoSQL databases utilize various data storage models, including key-value, graph, and document-oriented approaches.&lt;/p&gt;

&lt;h3&gt;
  
  
  Schema
&lt;/h3&gt;

&lt;p&gt;In SQL, each record follows a fixed schema, which means that the columns must be determined and chosen before data entry, and each row must contain data for each column. The schema can be modified later, but this involves modifying the database using migrations.&lt;/p&gt;

&lt;p&gt;NoSQL schemas are dynamic. Fields can be added on the fly, and each &lt;em&gt;record&lt;/em&gt; doesn’t have to contain data for each &lt;em&gt;field&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Querying
&lt;/h3&gt;

&lt;p&gt;SQL databases use Structured Query Language (SQL) to define and manipulate data, which is highly powerful.&lt;/p&gt;

&lt;p&gt;In a NoSQL database, queries focus on a collection of documents, with different databases having different syntax for querying.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Scalability&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In most cases, SQL databases can be scaled vertically, which can become very costly. While it's feasible to scale a relational database across multiple servers, it's a difficult and time-consuming process.&lt;/p&gt;

&lt;p&gt;NoSQL databases are horizontally scalable, which means it's easy to add more servers to handle large traffic. They can be hosted on inexpensive hardware or cloud instances, making them cost-effective compared to vertical scaling. Many NoSQL technologies also distribute data across servers automatically.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reliability
&lt;/h3&gt;

&lt;p&gt;The majority of relational databases are ACID compliant. Therefore, SQL databases are still the best choice for data reliability and transaction safety.&lt;/p&gt;

&lt;p&gt;Many NoSQL solutions prioritize performance and scalability over ACID compliance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reasons
&lt;/h2&gt;

&lt;p&gt;As always we should always pick the technology that fits the requirements better. So, let’s look at some reasons for picking SQL or NoSQL based database:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For SQL&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Structured data with strict schema&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Relational data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Need for complex joins&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Transactions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lookups by index are very fast&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;For NoSQL&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Dynamic or flexible schema&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Non-relational data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No need for complex joins&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Very data-intensive workload&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Very high throughput for IOPS&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's all folks.&lt;/p&gt;

&lt;p&gt;Feel free to comment on how you like my blog on the system design series or shoot me an email at &lt;a href="http://mailto:connect@nandan.dev" rel="noopener noreferrer"&gt;connect@nandan.dev&lt;/a&gt; If you have any queries I will try to answer them.&lt;/p&gt;

&lt;p&gt;You can also visit my website to read some of the articles at &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;https://nandan.dev/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stay tuned &amp;amp; connect with me on my social media channels. Subscribe to my newsletter to get regular updates on my upcoming posts.&lt;/p&gt;

&lt;p&gt;If you're interested in learning about system design, you can join Design Guru's course on &lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals?aff=y0pphf" rel="noopener noreferrer"&gt;System Design Fundamentals&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/_sirius93_" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; | &lt;a href="https://www.instagram.com/nandandotdev" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; | &lt;a href="https://github.com/sirius93" rel="noopener noreferrer"&gt;Github&lt;/a&gt; | &lt;a href="https://nandan.dev" rel="noopener noreferrer"&gt;Website&lt;/a&gt;&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>database</category>
      <category>mongodb</category>
      <category>sql</category>
    </item>
    <item>
      <title>System Design: Databases and DBMS</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Wed, 01 May 2024 14:46:55 +0000</pubDate>
      <link>https://dev.to/sirius93/system-design-databases-and-dbms-3nmh</link>
      <guid>https://dev.to/sirius93/system-design-databases-and-dbms-3nmh</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx727m4teikwxia35dvml.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx727m4teikwxia35dvml.png" alt="Poster for Databases" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What is a Database?
&lt;/h1&gt;

&lt;p&gt;A database is a structured collection of information or data that is typically stored electronically in a computer system. The management of the database is usually done by a Database Management System (DBMS). The combination of the data and the DBMS, along with the related applications, is commonly referred to as a database system, which is often shortened to just database.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is DBMS?
&lt;/h1&gt;

&lt;p&gt;A database is a collection of data that requires a comprehensive database software program, known as a Database Management System (DBMS), to function. Essentially, a DBMS serves as an interface between the database and its end-users or programs, allowing users to retrieve, update, and manage how the information is organized and optimized. Additionally, a DBMS enables oversight and control of databases, enabling a variety of administrative operations such as performance monitoring, tuning, backup, and recovery.&lt;/p&gt;

&lt;h2&gt;
  
  
  Components
&lt;/h2&gt;

&lt;p&gt;Here are some commonly found components that are present in different databases:&lt;/p&gt;

&lt;h3&gt;
  
  
  Schema
&lt;/h3&gt;

&lt;p&gt;A schema is responsible for defining the structure of a data storage system and specifying the types of data that can be stored in it. Schemas can be strictly enforced throughout the entire database, enforced loosely in some areas, or not enforced at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  Table
&lt;/h3&gt;

&lt;p&gt;Each table can have anywhere from two to over a hundred columns, depending on the type of information it contains, similar to a spreadsheet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Column
&lt;/h3&gt;

&lt;p&gt;A database column contains a single data value of a particular type for each row. The data value can be text, number, enum, timestamp, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Row
&lt;/h3&gt;

&lt;p&gt;Data in a table is recorded in rows. There can be thousands or millions of rows in a table having any particular information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwpc75zqw5pj7na6at6ll.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwpc75zqw5pj7na6at6ll.png" alt="database-types" width="800" height="161"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below are different types of databases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://nandan.dev/pages/courses/system-design/sql-databases" rel="noopener noreferrer"&gt;&lt;strong&gt;SQL&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://nandan.dev/pages/courses/system-design/nosql-databases" rel="noopener noreferrer"&gt;&lt;strong&gt;NoSQL&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Challenges
&lt;/h2&gt;

&lt;p&gt;Here's a revised version of the text to make it clearer and free of spelling, grammar, and punctuation errors:&lt;/p&gt;

&lt;p&gt;Running databases at scale can pose some common challenges that need to be addressed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Absorbing significant increases in data volume&lt;/strong&gt; : The explosion of data from sensors, connected machines, and other sources is increasing rapidly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ensuring data security&lt;/strong&gt; : Data breaches are becoming increasingly common, making it more important than ever to prioritize both data security and user accessibility.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keeping up with demand&lt;/strong&gt; : For timely decision-making and seizing new opportunities, companies require real-time access to their data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Managing and maintaining the database and infrastructure&lt;/strong&gt; : As data volumes increase and databases become more complex, companies face the expense of hiring additional talent to manage them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Removing scalability limits&lt;/strong&gt; : A business needs to grow to survive, and its data management must grow with it. However, predicting the required capacity of on-premises databases can be challenging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ensuring data residency, data sovereignty, or latency requirements&lt;/strong&gt; : Some organizations have use cases that are better suited to run on-premises. In those cases, engineered systems that are pre-configured and pre-optimized for running the database are ideal..&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  SQL databases
&lt;/h1&gt;

&lt;p&gt;A SQL or relational database is a collection of items that are related to each other and organized into tables consisting of columns and rows. These tables hold the information about the objects to be represented in the database. Each column in a table holds a specific type of data, and each field stores the actual value of an attribute. The rows in the table represent a collection of related values of one object or entity.&lt;/p&gt;

&lt;p&gt;Each row in a table can be identified uniquely with a primary key, and the rows among multiple tables can be related to each other using foreign keys. This data can be accessed in many different ways without the need to reorganize the database tables themselves. SQL databases usually follow the &lt;a href="https://nandan.dev/pages/courses/system-design/acid-and-base-consistency-models#base#acid" rel="noopener noreferrer"&gt;ACID consistency model&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Materialized views
&lt;/h2&gt;

&lt;p&gt;A materialized view is a pre-computed dataset that is derived from a query specification and stored for later use. The data is pre-computed, which makes querying a materialized view faster than executing a query against the base table of the view. This performance difference is significant when a query is run frequently or is complex.&lt;/p&gt;

&lt;p&gt;Materialized views enable data subsetting, which improves the performance of complex queries that run on large datasets and reduces network loads. Though there are other uses of materialized views, they are primarily used for performance and replication purposes.&lt;/p&gt;

&lt;h2&gt;
  
  
  N+1 query problem
&lt;/h2&gt;

&lt;p&gt;The N+1 query problem occurs when the data access layer executes additional SQL statements (N) to retrieve the same data that could have been obtained when executing the primary SQL query. The greater the value of N, the more queries will be executed, leading to a performance impact.&lt;/p&gt;

&lt;p&gt;This problem is commonly observed in GraphQL and ORM (Object-Relational Mapping) tools. It can be solved by optimizing the SQL query or by using a dataloader that batches consecutive requests and makes a single data request under the hood.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages
&lt;/h2&gt;

&lt;p&gt;Lets look at some advantages of using relational databases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Simple and accurate&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Accessibility&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Data consistency&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flexibility&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Disadvantages
&lt;/h2&gt;

&lt;p&gt;Below are the disadvantages of relational databases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Expensive to maintain&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Difficult schema evolution&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Performance hits (join, denormalization, etc.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Difficult to scale due to poor horizontal scalability&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;p&gt;Here are some commonly used relational databases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.postgresql.org/" rel="noopener noreferrer"&gt;PostgreSQL&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.mysql.com/" rel="noopener noreferrer"&gt;MySQL&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://mariadb.org/" rel="noopener noreferrer"&gt;MariaDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://aws.amazon.com/rds/aurora" rel="noopener noreferrer"&gt;Amazon Aurora&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  NoSQL databases
&lt;/h1&gt;

&lt;p&gt;NoSQL refers to a category of databases that do not primarily use SQL as their data access language. These databases are also known as non-relational databases. Unlike relational databases, NoSQL databases do not require data to follow a predefined schema. NoSQL databases follow &lt;a href="https://nandan.dev/pages/courses/system-design/acid-and-base-consistency-models#base" rel="noopener noreferrer"&gt;BASE consistency model&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Below are different types of NoSQL databases:&lt;/p&gt;

&lt;h3&gt;
  
  
  Document
&lt;/h3&gt;

&lt;p&gt;A document database, also known as a document-oriented database or a document store, is a versatile database that stores information in the form of documents. These databases can be used for transactional and analytical applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Intuitive and flexible&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy horizontal scaling&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Schemaless&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Schemaless&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Non-relational&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.mongodb.com/" rel="noopener noreferrer"&gt;MongoDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://aws.amazon.com/documentdb" rel="noopener noreferrer"&gt;Amazon DocumentDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://couchdb.apache.org/" rel="noopener noreferrer"&gt;CouchDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Key-value
&lt;/h3&gt;

&lt;p&gt;One of the simplest types of NoSQL databases, key-value databases save data as a group of key-value pairs made up of two data items each. Theyre also sometimes referred to as a key-value store.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Simple and performant&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Highly scalable for high volumes of traffic&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Session management&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Optimized lookups&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Basic CRUD&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Values cant be filtered&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lacks indexing and scanning capabilities&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Not optimized for complex queries&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://redis.io/" rel="noopener noreferrer"&gt;Redis&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://memcached.org/" rel="noopener noreferrer"&gt;Memcached&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://aws.amazon.com/dynamodb" rel="noopener noreferrer"&gt;Amazon DynamoDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://aerospike.com/" rel="noopener noreferrer"&gt;Aerospike&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Graph
&lt;/h3&gt;

&lt;p&gt;A graph database is a type of NoSQL database that uses graph structures to store and represent data. Instead of tables or documents, it uses nodes, edges, and properties to create relationships between data items.&lt;/p&gt;

&lt;p&gt;The nodes represent the data items, while the edges represent the relationships between them. The relationships allow data in the store to be linked together directly and can be retrieved with a single operation in many cases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Query speed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Agile and flexible&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Explicit data representation&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Complex&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No standardized query language&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use cases&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fraud detection&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Recommendation engines&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Social networks&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Network mapping&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://neo4j.com/" rel="noopener noreferrer"&gt;Neo4j&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.arangodb.com/" rel="noopener noreferrer"&gt;ArangoDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://aws.amazon.com/neptune" rel="noopener noreferrer"&gt;Amazon Neptune&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://janusgraph.org/" rel="noopener noreferrer"&gt;JanusGraph&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Time series
&lt;/h3&gt;

&lt;p&gt;A time-series database is a database optimized for time-stamped, or time series, data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fast insertion and retrieval&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Efficient data storage&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use cases&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;IoT data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Metrics analysis&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Application monitoring&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Understand financial trends&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.influxdata.com/" rel="noopener noreferrer"&gt;InfluxDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://druid.apache.org/" rel="noopener noreferrer"&gt;Apache Druid&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Wide column
&lt;/h3&gt;

&lt;p&gt;Wide column databases, also known as wide column stores, are schema-agnostic. Data is stored in column families, rather than in rows and columns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Highly scalable, can handle petabytes of data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ideal for real-time big data applications&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Expensive&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Increased write time&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use cases&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Business analytics&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Attribute-based data storage&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://cloud.google.com/bigtable" rel="noopener noreferrer"&gt;BigTable&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://cassandra.apache.org/" rel="noopener noreferrer"&gt;Apache Cassandra&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.scylladb.com/" rel="noopener noreferrer"&gt;ScyllaDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Multi-model
&lt;/h3&gt;

&lt;p&gt;Multi-model databases combine different database models (i.e. relational, graph, key-value, document, etc.) into a single, integrated backend. This means they can accommodate various data types, indexes, queries, and store data in more than one model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Flexibility&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Suitable for complex projects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Data consistent&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Complex&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Less mature&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.arangodb.com/" rel="noopener noreferrer"&gt;ArangoDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://azure.microsoft.com/en-in/services/cosmos-db" rel="noopener noreferrer"&gt;Azure Cosmos DB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.couchbase.com/" rel="noopener noreferrer"&gt;Couchbase&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's all folks.&lt;/p&gt;

&lt;p&gt;In the next blog, I will try to cover more about SQL V/s NoSQL Databases.&lt;/p&gt;

&lt;p&gt;Feel free to comment on how you like my blog on the system design series or shoot me an email at &lt;a href="http://mailto:connect@nandan.dev" rel="noopener noreferrer"&gt;connect@nandan.dev&lt;/a&gt; If you have any queries I will try to answer them.&lt;/p&gt;

&lt;p&gt;You can also visit my website to read some of the articles at &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;https://nandan.dev/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stay tuned &amp;amp; connect with me on my social media channels. Subscribe to my newsletter to get regular updates on my upcoming posts.&lt;/p&gt;

&lt;p&gt;If you're interested in learning about system design, you can join Design Guru's course on &lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals?aff=y0pphf" rel="noopener noreferrer"&gt;System Design Fundamentals&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/_sirius93_" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; | &lt;a href="https://www.instagram.com/nandandotdev" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; | &lt;a href="https://github.com/sirius93" rel="noopener noreferrer"&gt;Github&lt;/a&gt; | &lt;a href="https://nandan.dev" rel="noopener noreferrer"&gt;Website&lt;/a&gt;&lt;/p&gt;

</description>
      <category>design</category>
      <category>architecture</category>
      <category>database</category>
      <category>dbms</category>
    </item>
    <item>
      <title>System Design: Availablity, Scalability, and Types Of Storage.</title>
      <dc:creator>Nandan Kumar</dc:creator>
      <pubDate>Wed, 13 Dec 2023 03:58:41 +0000</pubDate>
      <link>https://dev.to/sirius93/system-design-availablity-scalability-and-types-of-storage-5hh</link>
      <guid>https://dev.to/sirius93/system-design-availablity-scalability-and-types-of-storage-5hh</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqn0hcfi081rss991sz0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqn0hcfi081rss991sz0h.png" alt="Availiblity Poster" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Availability
&lt;/h2&gt;

&lt;p&gt;Availability refers to the duration for which a system performs its intended function within a given timeframe. It measures the percentage of time a system or machine remains operational under normal circumstances, serving as a simple metric of operational continuity.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Nines of availability
&lt;/h3&gt;

&lt;p&gt;The "Nine's of availability" is a way to measure the reliability and uptime of a system. It is expressed as a percentage or number of nines, where each "nine" represents an additional decimal place of uptime.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Felhhybsuq48gd1so2vhp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Felhhybsuq48gd1so2vhp.png" alt="Avaiablity Image 1" width="800" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If availability is 99.00% available, it is said to have 2 nines of availability, and if it is 99.9%, it is called 3 nines, and so on.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Availability (Percent)&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Downtime (Year)&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Downtime (Month)&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Downtime (Week)&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;90% (one nine)&lt;/td&gt;
&lt;td&gt;36.53 days&lt;/td&gt;
&lt;td&gt;72 hours&lt;/td&gt;
&lt;td&gt;16.8 hours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;99% (two nines)&lt;/td&gt;
&lt;td&gt;3.65 days&lt;/td&gt;
&lt;td&gt;7.20 hours&lt;/td&gt;
&lt;td&gt;1.68 hours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;99.9% (three nines)&lt;/td&gt;
&lt;td&gt;8.77 hours&lt;/td&gt;
&lt;td&gt;43.8 minutes&lt;/td&gt;
&lt;td&gt;10.1 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;99.99% (four nines)&lt;/td&gt;
&lt;td&gt;52.6 minutes&lt;/td&gt;
&lt;td&gt;4.32 minutes&lt;/td&gt;
&lt;td&gt;1.01 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;99.999% (five nines)&lt;/td&gt;
&lt;td&gt;5.25 minutes&lt;/td&gt;
&lt;td&gt;25.9 seconds&lt;/td&gt;
&lt;td&gt;6.05 seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;99.9999% (six nines)&lt;/td&gt;
&lt;td&gt;31.56 seconds&lt;/td&gt;
&lt;td&gt;2.59 seconds&lt;/td&gt;
&lt;td&gt;604.8 milliseconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;99.99999% (seven nines)&lt;/td&gt;
&lt;td&gt;3.15 seconds&lt;/td&gt;
&lt;td&gt;263 milliseconds&lt;/td&gt;
&lt;td&gt;60.5 milliseconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;99.999999% (eight nines)&lt;/td&gt;
&lt;td&gt;315.6 milliseconds&lt;/td&gt;
&lt;td&gt;26.3 milliseconds&lt;/td&gt;
&lt;td&gt;6 milliseconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;99.9999999% (nine nines)&lt;/td&gt;
&lt;td&gt;31.6 milliseconds&lt;/td&gt;
&lt;td&gt;2.6 milliseconds&lt;/td&gt;
&lt;td&gt;0.6 milliseconds&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Availability in Sequence vs Parallel
&lt;/h2&gt;

&lt;p&gt;If a service consists of multiple components prone to failure, the services overall availability depends on whether the components are in sequence or in parallel.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sequence
&lt;/h3&gt;

&lt;p&gt;Overall availability decreases when two components are in sequence.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5513nrb4635iipa93yks.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5513nrb4635iipa93yks.png" alt="Avaiablity Image 2" width="800" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, if both &lt;code&gt;Foo&lt;/code&gt; and &lt;code&gt;Bar&lt;/code&gt; each had 99.9% availability, their total availability in sequence would be 99.8%.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parallel
&lt;/h3&gt;

&lt;p&gt;Overall availability increases when two components are in parallel.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqjvc7e280aufbftb2jxz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqjvc7e280aufbftb2jxz.png" alt="Avaiablity Image 3" width="800" height="71"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, if both &lt;code&gt;Foo&lt;/code&gt; and &lt;code&gt;Bar&lt;/code&gt; each had 99.9% availability, their total availability in parallel would be 99.9999%.&lt;/p&gt;

&lt;h2&gt;
  
  
  Availability vs Reliability
&lt;/h2&gt;

&lt;p&gt;If a system is reliable, it means it is available. However, if a system is available, it does not necessarily mean it is reliable. This means that a system with high reliability will also have high availability, but a system can still achieve high availability without being reliable.&lt;/p&gt;

&lt;h2&gt;
  
  
  High Availability vs Fault Tolerance
&lt;/h2&gt;

&lt;p&gt;Both high availability and fault tolerance are methods for achieving high uptime levels, but they work differently.&lt;/p&gt;

&lt;p&gt;A fault-tolerant system ensures that there is no service interruption, but it comes at a higher cost. On the other hand, a highly available system minimizes service interruption. To achieve fault tolerance, hardware redundancy is essential. In case the main system fails, another system takes over without any loss in uptime.&lt;/p&gt;

&lt;h1&gt;
  
  
  Scalability
&lt;/h1&gt;

&lt;p&gt;Scalability is the measure of how well a system responds to changes by adding or removing resources to meet demands.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5qohsw00ay77i7811dhf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5qohsw00ay77i7811dhf.png" alt="scalability" width="800" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets discuss different types of scaling:&lt;/p&gt;

&lt;h2&gt;
  
  
  Vertical scaling
&lt;/h2&gt;

&lt;p&gt;Vertical scaling (also known as scaling up) expands a systems scalability by adding more power to an existing machine. In other words, vertical scaling refers to improving an applications capability via increasing hardware capacity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Simple to implement&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easier to manage&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Data consistent&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Risk of high downtime&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Harder to upgrade&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can be a single point of failure&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Horizontal scaling
&lt;/h2&gt;

&lt;p&gt;Horizontal scaling (also known as scaling out) expands a systems scale by adding more machines. It improves the performance of the server by adding more instances to the existing pool of servers, allowing the load to be distributed more evenly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Increased redundancy&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Better fault tolerance&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flexible and efficient&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easier to upgrade&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Increased complexity&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Data inconsistency&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Increased load on downstream services&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Storage
&lt;/h1&gt;

&lt;p&gt;Storage is a mechanism that enables a system to retain data, either temporarily or permanently. This topic is mostly skipped over in the context of system design, however, it is important to have a basic understanding of some common types of storage techniques that can help us fine-tune our storage components. Lets discuss some important storage concepts:&lt;/p&gt;

&lt;h2&gt;
  
  
  RAID
&lt;/h2&gt;

&lt;p&gt;RAID (Redundant Array of Independent Disks) is a way of storing the same data on multiple hard disks or solid-state drives (SSDs) to protect data in the case of a drive failure.&lt;/p&gt;

&lt;p&gt;There are different RAID levels, however, and not all have the goal of providing redundancy. Lets discuss some commonly used RAID levels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RAID 0&lt;/strong&gt; : Also known as striping, data is split evenly across all the drives in the array.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RAID 1&lt;/strong&gt; : Also known as mirroring, at least two drives contains the exact copy of a set of data. If a drive fails, others will still work.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RAID 5&lt;/strong&gt; : Striping with parity. Requires the use of at least 3 drives, striping the data across multiple drives like RAID 0, but also has a parity distributed across the drives.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RAID 6&lt;/strong&gt; : Striping with double parity. RAID 6 is like RAID 5, but the parity data are written to two drives.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RAID 10&lt;/strong&gt; : Combines striping plus mirroring from RAID 0 and RAID 1. It provides security by mirroring all data on secondary drives while using striping across each set of drives to speed up data transfers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Comparison
&lt;/h3&gt;

&lt;p&gt;Lets compare all the features of different RAID levels:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Features&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;RAID 0&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;RAID 1&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;RAID 5&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;RAID 6&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;RAID 10&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Description&lt;/td&gt;
&lt;td&gt;Striping&lt;/td&gt;
&lt;td&gt;Mirroring&lt;/td&gt;
&lt;td&gt;Striping with Parity&lt;/td&gt;
&lt;td&gt;Striping with double parity&lt;/td&gt;
&lt;td&gt;Striping and Mirroring&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Minimum Disks&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Read Performance&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Write Performance&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fault Tolerance&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;Single-drive failure&lt;/td&gt;
&lt;td&gt;Single-drive failure&lt;/td&gt;
&lt;td&gt;Two-drive failure&lt;/td&gt;
&lt;td&gt;Up to one disk failure in each sub-array&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Capacity Utilization&lt;/td&gt;
&lt;td&gt;100%&lt;/td&gt;
&lt;td&gt;50%&lt;/td&gt;
&lt;td&gt;67%-94%&lt;/td&gt;
&lt;td&gt;50%-80%&lt;/td&gt;
&lt;td&gt;50%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Volumes
&lt;/h2&gt;

&lt;p&gt;"Volume" refers to a fixed amount of storage space on a disk or tape. Although the term "volume" is often used interchangeably with "storage," it is important to note that a single disk can contain multiple volumes, or a volume can span across multiple disks.&lt;/p&gt;

&lt;h2&gt;
  
  
  File storage
&lt;/h2&gt;

&lt;p&gt;File storage is a method used to store data in a hierarchical directory structure and present it to users. It is a user-friendly solution that provides easy storage and retrieval of files. In order to locate a file in file storage, one must know the complete path of the file. It is an economical and well-structured method that is commonly used on hard drives. This means that files appear exactly the same for the user and on the hard drive.&lt;/p&gt;

&lt;p&gt;Example: &lt;a href="https://aws.amazon.com/efs" rel="noopener noreferrer"&gt;Amazon EFS&lt;/a&gt;, &lt;a href="https://azure.microsoft.com/en-in/services/storage/files" rel="noopener noreferrer"&gt;Azure files&lt;/a&gt;, &lt;a href="https://cloud.google.com/filestore" rel="noopener noreferrer"&gt;Google Cloud Filestore&lt;/a&gt;, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Block storage
&lt;/h2&gt;

&lt;p&gt;Block storage is a method of storing data by dividing it into blocks or chunks, which are then stored as separate entities. Each block is given a unique identifier, which enables the system to store the smaller pieces of data wherever it is most convenient.&lt;/p&gt;

&lt;p&gt;Block storage separates data from user environments, making it possible for data to be spread across multiple environments. This creates multiple paths to the data and enables users to retrieve it quickly. When a user or application requests data from the block storage system, the system reassembles the data blocks and presents the data to the user or application.&lt;/p&gt;

&lt;p&gt;Example: &lt;a href="https://aws.amazon.com/ebs" rel="noopener noreferrer"&gt;Amazon EBS&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Object Storage
&lt;/h2&gt;

&lt;p&gt;Object storage, also known as object-based storage, divides data files into smaller units called objects. These objects are then stored in a single repository that can be distributed across multiple networked systems.&lt;/p&gt;

&lt;p&gt;Example: &lt;a href="https://aws.amazon.com/s3" rel="noopener noreferrer"&gt;Amazon S3&lt;/a&gt;, &lt;a href="https://azure.microsoft.com/en-in/services/storage/blobs" rel="noopener noreferrer"&gt;Azure Blob Storage&lt;/a&gt;, &lt;a href="https://cloud.google.com/storage" rel="noopener noreferrer"&gt;Google Cloud Storage&lt;/a&gt;, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  NAS
&lt;/h2&gt;

&lt;p&gt;A Network Attached Storage (NAS) is a device that is connected to a network and allows authorized users to store and retrieve data from a central location. The NAS device is flexible, which means that we can easily add more storage capacity as needed. It is faster and less expensive than using a public cloud service, and it provides all the benefits of cloud storage while giving us complete control over our data.&lt;/p&gt;

&lt;h2&gt;
  
  
  HDFS
&lt;/h2&gt;

&lt;p&gt;The Hadoop Distributed File System (HDFS) is a file system that can be distributed across multiple machines in a cluster. It's designed to run on inexpensive hardware and is highly fault-tolerant. HDFS offers high-throughput access to large datasets, making it ideal for applications that require handling of massive data.&lt;/p&gt;

&lt;p&gt;HDFS uses a block-based approach for storing files. Each file is divided into a sequence of blocks, with all blocks in a file (except the last one) being of the same size. For reliability, the blocks of a file are replicated across different machines in the cluster.&lt;/p&gt;

&lt;p&gt;That's all folks.&lt;/p&gt;

&lt;p&gt;In the next blog, I will try to cover more about Databases.&lt;/p&gt;

&lt;p&gt;Feel free to comment on how you like my blog on the system design series or shoot me a mail at &lt;a href="http://mailto:connect@nandan.dev" rel="noopener noreferrer"&gt;connect@nandan.dev&lt;/a&gt; If you have any queries I will try to answer.&lt;/p&gt;

&lt;p&gt;You can also visit my website to read some of the articles at &lt;a href="https://nandan.dev/" rel="noopener noreferrer"&gt;https://nandan.dev/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stay tuned &amp;amp; connect with me on my social media channels. Subscribe to my newsletter to get regular updates on my upcoming posts.&lt;/p&gt;

&lt;p&gt;If you're interested in learning about system design, you can join Design Guru's course on &lt;a href="https://www.designgurus.io/course/grokking-system-design-fundamentals?aff=y0pphf" rel="noopener noreferrer"&gt;System Design Fundamentals&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/_sirius93_" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; | &lt;a href="https://www.instagram.com/nandandotdev" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; | &lt;a href="https://github.com/sirius93" rel="noopener noreferrer"&gt;Github&lt;/a&gt; | &lt;a href="https://nandan.dev" rel="noopener noreferrer"&gt;Website&lt;/a&gt;&lt;/p&gt;

</description>
      <category>availability</category>
      <category>scalability</category>
      <category>storage</category>
      <category>design</category>
    </item>
  </channel>
</rss>
