<?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: Noor ul hassan</title>
    <description>The latest articles on DEV Community by Noor ul hassan (@codewithnuh).</description>
    <link>https://dev.to/codewithnuh</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F999733%2Fceb79fc7-cf5a-4e83-a3ff-ec1ef7aee9ee.jpeg</url>
      <title>DEV Community: Noor ul hassan</title>
      <link>https://dev.to/codewithnuh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codewithnuh"/>
    <language>en</language>
    <item>
      <title>Blockend Logger vs Traditional Pino Logger</title>
      <dc:creator>Noor ul hassan</dc:creator>
      <pubDate>Sat, 18 Jul 2026 13:31:04 +0000</pubDate>
      <link>https://dev.to/codewithnuh/blockend-logger-vs-traditional-pino-logger-2k06</link>
      <guid>https://dev.to/codewithnuh/blockend-logger-vs-traditional-pino-logger-2k06</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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4b556m7colu9chl4fqjv.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4b556m7colu9chl4fqjv.png" alt="Comparison between blockend logo and traditional pino logger image" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
Logging is essential, but setting it up with &lt;strong&gt;Pino&lt;/strong&gt; often means boilerplate: installing packages, wiring middleware, passing request IDs manually, and configuring redaction yourself. It works, but it’s repetitive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Blockend Logger&lt;/strong&gt; takes a different approach. It uses Pino under the hood but generates a ready‑to‑use, type‑safe logger block directly into your project. You own the code, you can debug it, and you can change it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Blockend Logger Feels Different
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Shared logger instance across your app&lt;/li&gt;
&lt;li&gt;Automatic request ID propagation with &lt;code&gt;AsyncLocalStorage&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Framework adapters generated automatically (Express, Fastify, Hono)&lt;/li&gt;
&lt;li&gt;Request logging out of the box&lt;/li&gt;
&lt;li&gt;Built‑in redaction for sensitive fields&lt;/li&gt;
&lt;li&gt;Pretty logs in dev, JSON logs in prod&lt;/li&gt;
&lt;li&gt;TypeScript support baked in&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Honest Comparison
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Blockend Logger&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Traditional Pino&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Setup&lt;/td&gt;
&lt;td&gt;&lt;code&gt;blockend-cli add logger&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Manual install + config&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Request IDs&lt;/td&gt;
&lt;td&gt;Automatic&lt;/td&gt;
&lt;td&gt;Manual middleware&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Framework integration&lt;/td&gt;
&lt;td&gt;Auto‑generated adapter&lt;/td&gt;
&lt;td&gt;Write your own&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Request logging&lt;/td&gt;
&lt;td&gt;Built‑in&lt;/td&gt;
&lt;td&gt;Add middleware manually&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Redaction&lt;/td&gt;
&lt;td&gt;Preconfigured&lt;/td&gt;
&lt;td&gt;Manual setup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Output modes&lt;/td&gt;
&lt;td&gt;Pretty dev / JSON prod&lt;/td&gt;
&lt;td&gt;Configure transports yourself&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TypeScript&lt;/td&gt;
&lt;td&gt;Generated &lt;code&gt;.ts&lt;/code&gt; files&lt;/td&gt;
&lt;td&gt;Manual typings&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Blockend isn’t replacing Pino — it’s making Pino easier to use. If you want raw control, stick with Pino. If you want sane defaults and less boilerplate, Blockend Logger saves you time.&lt;/p&gt;




&lt;h2&gt;
  
  
  Learn More
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Docs: &lt;a href="https://blockend.noorulhassan.com/docs/02-blocks/03-pino-logger" rel="noopener noreferrer"&gt;Blockend Logger Documentation&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Source: &lt;a href="https://github.com/codewithnuh/blockend" rel="noopener noreferrer"&gt;Blockend on GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final Word
&lt;/h2&gt;

&lt;p&gt;Logging should help you debug, not slow you down. Blockend Logger is basically &lt;strong&gt;“Pino with batteries included.”&lt;/strong&gt; If you love it, &lt;strong&gt;star it on GitHub&lt;/strong&gt; — that’s the best way to support the project and help more developers discover it.&lt;/p&gt;

</description>
      <category>node</category>
      <category>backend</category>
      <category>logger</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Build a Dynamic Array in C from Scratch</title>
      <dc:creator>Noor ul hassan</dc:creator>
      <pubDate>Tue, 14 Jul 2026 13:04:46 +0000</pubDate>
      <link>https://dev.to/codewithnuh/build-a-dynamic-array-in-c-from-scratch-2po9</link>
      <guid>https://dev.to/codewithnuh/build-a-dynamic-array-in-c-from-scratch-2po9</guid>
      <description>&lt;h1&gt;
  
  
  Build a Dynamic Array in C from Scratch
&lt;/h1&gt;

&lt;p&gt;You've used &lt;code&gt;push()&lt;/code&gt; in JavaScript, &lt;code&gt;append()&lt;/code&gt; in Python, &lt;code&gt;add()&lt;/code&gt; in Java. They feel instant. They never run out of space. You never think about them.&lt;/p&gt;

&lt;p&gt;That's a problem — not because those abstractions are bad, but because you're using a tool without knowing what it costs. Every one of those methods is built on ideas you can understand completely. This article will show you how, in C, where the machine hides nothing from you.&lt;/p&gt;

&lt;p&gt;By the end you'll have built a working dynamic array and, more importantly, a mental model that makes &lt;code&gt;std::vector&lt;/code&gt;, Go slices, and Rust's &lt;code&gt;Vec&lt;/code&gt; all obvious.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Core Idea: Two Layers of Memory
&lt;/h2&gt;

&lt;p&gt;Before writing a single line, you need to understand the central insight that makes a dynamic array possible.&lt;/p&gt;

&lt;p&gt;A normal array is a fixed block of memory. You declare &lt;code&gt;int numbers[8]&lt;/code&gt; and the compiler carves out exactly 32 bytes on the stack. That's it. If you need a 9th element, you're stuck.&lt;/p&gt;

&lt;p&gt;A dynamic array gets around this by living on the &lt;strong&gt;heap&lt;/strong&gt; — a region of memory that your program can request and release at runtime, in any size, at any time. The heap doesn't get freed automatically when a function returns. You control it. That control is what makes resizing possible, and what makes memory bugs possible too.&lt;/p&gt;

&lt;p&gt;The dynamic array is two things at once: a block of integers sitting somewhere on the heap, and a small control structure that remembers where that block is, how big it is, and how many elements are currently in it. Everything we build is just bookkeeping those two things correctly.&lt;/p&gt;




&lt;h2&gt;
  
  
  What You Need to Know First
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Memory: Stack vs Heap
&lt;/h3&gt;

&lt;p&gt;When you declare a local variable, it goes on the &lt;strong&gt;stack&lt;/strong&gt;. The stack is fast and automatic — variables appear when a function is called and vanish when it returns.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// lives on the stack&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;               &lt;span class="c1"&gt;// x is gone here&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;strong&gt;heap&lt;/strong&gt; is different. Memory there persists until you explicitly free it. You ask the OS for a chunk, use it, and free it when you're done. This is what enables data structures that outlive the function that created them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pointers
&lt;/h3&gt;

&lt;p&gt;A pointer is a variable that holds a memory address rather than a value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;ptr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ptr holds the address of score, not 99&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;&amp;amp;score&lt;/code&gt; means "give me the address of score." &lt;code&gt;*ptr&lt;/code&gt; means "go to that address and read what's there." They're inverse operations.&lt;/p&gt;

&lt;p&gt;Why does this matter? Because when you allocate memory on the heap, you get back an address — a pointer — to where that memory starts. There's no other way to refer to heap memory. Pointers aren't a language quirk; they're the only handle you have on dynamic allocation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// numbers holds the address of a 32-byte block on the heap&lt;/span&gt;
&lt;span class="c1"&gt;// numbers[0], numbers[1], ... numbers[7] are all valid&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;malloc&lt;/code&gt; returns a pointer to the allocated block. &lt;code&gt;sizeof(int)&lt;/code&gt; gives the size in bytes of one integer (typically 4). Multiply by 8 and you get 32 bytes — room for 8 integers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Structs
&lt;/h3&gt;

&lt;p&gt;C has no classes. To group related data, you use a &lt;code&gt;struct&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c1"&gt;// pointer to the integers on the heap&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="c1"&gt;// how many elements are currently stored&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// how much space is allocated&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;typedef&lt;/code&gt; lets you drop the &lt;code&gt;struct&lt;/code&gt; keyword every time you use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;IntArray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now &lt;code&gt;IntArray arr;&lt;/code&gt; is valid instead of &lt;code&gt;struct IntArray arr;&lt;/code&gt;. Small thing, but it adds up.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;-&amp;gt;&lt;/code&gt; operator accesses a struct's field through a pointer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;  &lt;span class="c1"&gt;// same as (*array).length&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll use &lt;code&gt;-&amp;gt;&lt;/code&gt; constantly because our functions always receive a pointer to the struct, not the struct itself. Passing the struct by value would copy all three fields every time — wasteful, and it means modifications wouldn't be visible to the caller.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Header Files
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt;   // printf, scanf&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt;  // malloc, realloc, free, exit&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdbool.h&amp;gt;&lt;/span&gt;&lt;span class="c1"&gt; // bool, true, false&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;stdlib.h&lt;/code&gt; is the critical one. Every memory function we use lives there. Without it, &lt;code&gt;malloc&lt;/code&gt; and &lt;code&gt;free&lt;/code&gt; are undeclared.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;stdbool.h&lt;/code&gt; exists because C didn't originally have a boolean type. It gives you &lt;code&gt;bool&lt;/code&gt;, &lt;code&gt;true&lt;/code&gt;, and &lt;code&gt;false&lt;/code&gt; as proper names instead of &lt;code&gt;int&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt;, and &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Structure
&lt;/h2&gt;

&lt;p&gt;Now that the building blocks are clear, the struct makes obvious sense:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="cp"&gt;#define DEFAULT_CAPACITY 8
&lt;/span&gt;
&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;     &lt;span class="c1"&gt;// address of our integer block on the heap&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="c1"&gt;// elements currently stored (logical size)&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// elements we have room for (physical size)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;IntArray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;length&lt;/code&gt; and &lt;code&gt;capacity&lt;/code&gt; are not the same thing. This distinction is the heart of how a dynamic array works.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;capacity = 8  (8 slots exist in memory)
length   = 3  (only 3 are in use)

[ 10 | 20 | 30 | __ | __ | __ | __ | __ ]
  [0]  [1]  [2]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When &lt;code&gt;length == capacity&lt;/code&gt;, the array is full and must grow before the next &lt;code&gt;add&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;#define DEFAULT_CAPACITY 8&lt;/code&gt; is a compile-time constant. The preprocessor replaces every occurrence of &lt;code&gt;DEFAULT_CAPACITY&lt;/code&gt; with &lt;code&gt;8&lt;/code&gt; before the compiler sees the code. It's not a variable — it has no address and uses no runtime memory.&lt;/p&gt;




&lt;h2&gt;
  
  
  Creating the Array
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nf"&gt;createArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="c1"&gt;// Guard against nonsense input&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;capacity&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;capacity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;DEFAULT_CAPACITY&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Allocate the control struct on the heap&lt;/span&gt;
    &lt;span class="c1"&gt;// This gives us room for: one pointer, two ints&lt;/span&gt;
    &lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Memory allocation failed&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// no safe way to recover here&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Allocate the integer block separately&lt;/span&gt;
    &lt;span class="c1"&gt;// The struct just holds a pointer to this block&lt;/span&gt;
    &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Memory allocation failed&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// don't leak the struct we just allocated&lt;/span&gt;
        &lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;        &lt;span class="c1"&gt;// no elements yet&lt;/span&gt;
    &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;capacity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// but we have space reserved&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// return the address of the struct&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice we allocate &lt;strong&gt;twice&lt;/strong&gt;. Once for the struct, and once for the integer data. These are two separate heap allocations, and that's why we must free both when we're done. The struct contains the address of the data block, but it doesn't own it in any automatic sense — we have to track and free it ourselves.&lt;/p&gt;

&lt;p&gt;The return type is &lt;code&gt;IntArray *&lt;/code&gt; — a pointer. We're not returning the struct itself; we're returning its address. This is the handle the caller will use for every subsequent operation.&lt;/p&gt;




&lt;h2&gt;
  
  
  Destroying the Array
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;destroyArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// free the integer block first&lt;/span&gt;
    &lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;       &lt;span class="c1"&gt;// then free the struct&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Order matters. Free the data block first, then the struct. If you freed the struct first, &lt;code&gt;array-&amp;gt;data&lt;/code&gt; would be a dangling read — you'd be accessing memory through a pointer to something that's already freed.&lt;/p&gt;

&lt;p&gt;Every &lt;code&gt;malloc&lt;/code&gt; must have exactly one matching &lt;code&gt;free&lt;/code&gt;. This is the discipline C demands. Modern languages have garbage collectors to enforce this automatically. In C, it's on you.&lt;/p&gt;




&lt;h2&gt;
  
  
  Getting and Setting Elements
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Index out of bounds&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Index out of bounds&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The bounds check is not optional. Without it, &lt;code&gt;array-&amp;gt;data[index]&lt;/code&gt; when &lt;code&gt;index &amp;gt;= length&lt;/code&gt; reads memory that belongs to something else — possibly another variable, possibly the OS. C won't stop you. The behavior is undefined, which in practice means silent data corruption or a crash that's hard to trace.&lt;/p&gt;

&lt;p&gt;Both operations are &lt;strong&gt;O(1)&lt;/strong&gt; because &lt;code&gt;array-&amp;gt;data[index]&lt;/code&gt; computes directly to a memory address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;address = base_address + (index × sizeof(int))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No searching. One arithmetic operation.&lt;/p&gt;




&lt;h2&gt;
  
  
  Adding Elements: The Core of a Dynamic Array
&lt;/h2&gt;

&lt;p&gt;This is the function everything else builds toward.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="c1"&gt;// Is the array full?&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

        &lt;span class="c1"&gt;// Double the capacity — we'll explain why below&lt;/span&gt;
        &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;capacity&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="c1"&gt;// Ask the OS to resize our integer block&lt;/span&gt;
        &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;newData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;realloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;capacity&lt;/span&gt;
        &lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// CRITICAL: store in a temp pointer, not array-&amp;gt;data&lt;/span&gt;
        &lt;span class="c1"&gt;// If realloc fails, it returns NULL — if we assigned&lt;/span&gt;
        &lt;span class="c1"&gt;// directly to array-&amp;gt;data we'd lose the original pointer&lt;/span&gt;
        &lt;span class="c1"&gt;// and have a memory leak with no way to recover&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newData&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Reallocation failed&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// Only update once we know it succeeded&lt;/span&gt;
        &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;newData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Store the value and advance the length in one step&lt;/span&gt;
    &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;realloc&lt;/code&gt; is &lt;code&gt;malloc&lt;/code&gt;'s smarter sibling. It takes an existing pointer and a new size. If it can extend the block in place, it does. If not, it allocates a new block, copies the old data, frees the old block, and returns the new address. The existing contents are preserved either way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why double the capacity instead of growing by 1?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you grew by 1 every time the array filled up, every single &lt;code&gt;add&lt;/code&gt; would trigger a &lt;code&gt;realloc&lt;/code&gt; and a copy of all existing elements. Adding &lt;code&gt;n&lt;/code&gt; elements would cost &lt;code&gt;O(n²)&lt;/code&gt; total.&lt;/p&gt;

&lt;p&gt;Doubling means resizes happen at sizes 4, 8, 16, 32, 64... Each resize copies everything, but the number of copies per element approaches 2 as &lt;code&gt;n&lt;/code&gt; grows. Over many insertions, the average cost per &lt;code&gt;add&lt;/code&gt; is &lt;strong&gt;O(1)&lt;/strong&gt;. This is called &lt;strong&gt;amortized constant time&lt;/strong&gt; — expensive occasionally, cheap on average.&lt;/p&gt;




&lt;h2&gt;
  
  
  Removing Elements
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Remove by Index
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;removeAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Index out of bounds&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Shift every element after the removed one left by one position&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// The last position still holds the old value, but we don't&lt;/span&gt;
    &lt;span class="c1"&gt;// erase it — we just stop counting it as part of the array&lt;/span&gt;
    &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The loop goes to &lt;code&gt;array-&amp;gt;length - 1&lt;/code&gt;, not &lt;code&gt;array-&amp;gt;length&lt;/code&gt;. At the final iteration, &lt;code&gt;i&lt;/code&gt; is &lt;code&gt;length - 2&lt;/code&gt; and we read &lt;code&gt;array-&amp;gt;data[length - 1]&lt;/code&gt;. If the loop ran to &lt;code&gt;length&lt;/code&gt;, the last iteration would read &lt;code&gt;array-&amp;gt;data[length]&lt;/code&gt;, which is outside the allocated block.&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;O(n)&lt;/strong&gt; in the worst case — removing from index 0 shifts every element.&lt;/p&gt;

&lt;h3&gt;
  
  
  Remove by Value
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;bool&lt;/span&gt; &lt;span class="nf"&gt;removeValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;removeAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// remove first match only&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// value wasn't in the array&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Search linearly, delegate the actual removal to &lt;code&gt;removeAt&lt;/code&gt;. Returns &lt;code&gt;false&lt;/code&gt; when the value isn't found so the caller can detect the miss.&lt;/p&gt;




&lt;h2&gt;
  
  
  Reversing the Array
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Swap elements at left and right&lt;/span&gt;
        &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
        &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="c1"&gt;// Move both pointers inward&lt;/span&gt;
        &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The two-pointer technique. Start from opposite ends, swap, move inward, stop when they meet. &lt;strong&gt;O(n)&lt;/strong&gt; time, &lt;strong&gt;O(1)&lt;/strong&gt; extra space — no second array needed.&lt;/p&gt;

&lt;p&gt;The condition is &lt;code&gt;left &amp;lt; right&lt;/code&gt;, not &lt;code&gt;left != right&lt;/code&gt;. For an odd-length array, they'll converge on the middle element. That element doesn't need swapping with itself, so the loop correctly stops before touching it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Printing
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;printArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"["&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%d"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;", "&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"]&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The comma logic — print a comma after every element except the last — is a common pattern. The alternative (printing a comma before every element except the first) is equivalent; pick one and be consistent.&lt;/p&gt;




&lt;h2&gt;
  
  
  Putting It Together
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;createArray&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="c1"&gt;// capacity 4, length 0&lt;/span&gt;

    &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&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="c1"&gt;// length 1&lt;/span&gt;
    &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// length 2&lt;/span&gt;
    &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// length 3&lt;/span&gt;
    &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// length 4, capacity 4 — full&lt;/span&gt;

    &lt;span class="n"&gt;printArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// [3, 7, 6, -2]&lt;/span&gt;

    &lt;span class="n"&gt;removeValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// shift left, length becomes 3&lt;/span&gt;

    &lt;span class="n"&gt;printArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// [3, 6, -2]&lt;/span&gt;

    &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// two-pointer swap&lt;/span&gt;

    &lt;span class="n"&gt;printArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// [-2, 6, 3]&lt;/span&gt;

    &lt;span class="n"&gt;destroyArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// free data block, then free struct&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: the first &lt;code&gt;add&lt;/code&gt; after &lt;code&gt;createArray(4)&lt;/code&gt; that would require a 5th slot would trigger a resize — capacity doubles to 8. In this &lt;code&gt;main&lt;/code&gt; we add exactly 4 elements, so no resize occurs. To see it in action, add a 5th element.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Gotchas
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Assigning &lt;code&gt;realloc&lt;/code&gt; directly to the original pointer.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Wrong — if realloc returns NULL, you've lost your data&lt;/span&gt;
&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;realloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newSize&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Right — check before assigning&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;newData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;realloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newSize&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newData&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;newData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Freeing in the wrong order.&lt;/strong&gt;&lt;br&gt;
Free &lt;code&gt;array-&amp;gt;data&lt;/code&gt; before &lt;code&gt;array&lt;/code&gt;. If you free the struct first, you're reading &lt;code&gt;array-&amp;gt;data&lt;/code&gt; through a dangling pointer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using &lt;code&gt;length&lt;/code&gt; instead of &lt;code&gt;capacity&lt;/code&gt; in the resize check.&lt;/strong&gt;&lt;br&gt;
The array is full when &lt;code&gt;length == capacity&lt;/code&gt;. If you compare against the wrong field, you either resize too early (wasted allocations) or never resize at all (out-of-bounds writes).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Off-by-one in &lt;code&gt;removeAt&lt;/code&gt;'s loop.&lt;/strong&gt;&lt;br&gt;
The loop runs to &lt;code&gt;array-&amp;gt;length - 1&lt;/code&gt;, not &lt;code&gt;array-&amp;gt;length&lt;/code&gt;. The last iteration reads &lt;code&gt;data[length - 1]&lt;/code&gt;. Going one further reads past the end of the allocated block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not checking &lt;code&gt;malloc&lt;/code&gt; for &lt;code&gt;NULL&lt;/code&gt;.&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;malloc&lt;/code&gt; returns &lt;code&gt;NULL&lt;/code&gt; when the OS can't satisfy the request. Dereferencing a &lt;code&gt;NULL&lt;/code&gt; pointer is undefined behavior. Always check.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using the array after &lt;code&gt;destroyArray&lt;/code&gt;.&lt;/strong&gt;&lt;br&gt;
After you free memory, the pointer still holds the old address. Reading through it is undefined behavior. Set pointers to &lt;code&gt;NULL&lt;/code&gt; after freeing if you need to guard against accidental reuse.&lt;/p&gt;


&lt;h2&gt;
  
  
  Junior Pattern vs Senior Pattern
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Resizing:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Junior — assigns directly, leaks memory on failure&lt;/span&gt;
&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;realloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// original pointer is gone&lt;/span&gt;

&lt;span class="c1"&gt;// Senior — uses temp, original is recoverable on failure&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;newData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;realloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newData&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// array-&amp;gt;data is still valid here, nothing was lost&lt;/span&gt;
    &lt;span class="n"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EXIT_FAILURE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;newData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Cleanup:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Junior — frees struct first, then reads dangling pointer&lt;/span&gt;
&lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// undefined behavior: array is already freed&lt;/span&gt;

&lt;span class="c1"&gt;// Senior — free data first, then the container&lt;/span&gt;
&lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Bounds checking:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Junior — trusts the caller&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// Senior — validates before accessing&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// handle error&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Where This Lives in the Real World
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;std::vector&lt;/code&gt; in C++ is this exact structure. The underlying implementation uses &lt;code&gt;new[]&lt;/code&gt; instead of &lt;code&gt;malloc&lt;/code&gt;, but the capacity/length distinction, the doubling strategy, and the contiguous memory layout are identical.&lt;/p&gt;

&lt;p&gt;Go slices have a header with &lt;code&gt;ptr&lt;/code&gt;, &lt;code&gt;len&lt;/code&gt;, and &lt;code&gt;cap&lt;/code&gt; — those are our &lt;code&gt;data&lt;/code&gt;, &lt;code&gt;length&lt;/code&gt;, and &lt;code&gt;capacity&lt;/code&gt;. When you &lt;code&gt;append&lt;/code&gt; past &lt;code&gt;cap&lt;/code&gt;, Go allocates a new backing array, copies, and returns a new slice header.&lt;/p&gt;

&lt;p&gt;Rust's &lt;code&gt;Vec&amp;lt;T&amp;gt;&lt;/code&gt; is the same: a heap-allocated contiguous buffer, a length, and a capacity. The ownership system handles the freeing automatically, but the memory layout underneath is what you just built.&lt;/p&gt;




&lt;h2&gt;
  
  
  Time Complexity
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operation&lt;/th&gt;
&lt;th&gt;Complexity&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;get&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;Direct address calculation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;set&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;Direct address calculation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;add&lt;/code&gt; (no resize)&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;Write to &lt;code&gt;data[length]&lt;/code&gt;, increment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;add&lt;/code&gt; (resize)&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;realloc&lt;/code&gt; copies all elements&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;add&lt;/code&gt; (amortized)&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;Resizes are infrequent enough&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;removeAt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;Shift all elements after index&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;removeValue&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;Linear scan + shift&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;reverse&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;Visit each element once&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Your Turn
&lt;/h2&gt;

&lt;p&gt;Extend the implementation with these two functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Insert a value at a specific index, shifting everything right&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;insertAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Return the index of the first occurrence of value, or -1 if not found&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Constraints: &lt;code&gt;insertAt&lt;/code&gt; must handle growth the same way &lt;code&gt;add&lt;/code&gt; does. &lt;code&gt;indexOf&lt;/code&gt; must return &lt;code&gt;-1&lt;/code&gt;, not exit, when the value is absent.&lt;/p&gt;

&lt;p&gt;You'll know you're done when this &lt;code&gt;main&lt;/code&gt; produces the expected output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="n"&gt;IntArray&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;createArray&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="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;insertAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&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;20&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// insert 20 between 10 and 30&lt;/span&gt;
&lt;span class="n"&gt;printArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;      &lt;span class="c1"&gt;// [10, 20, 30]&lt;/span&gt;
&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;
&lt;span class="n"&gt;printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%d&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// -1&lt;/span&gt;
&lt;span class="n"&gt;destroyArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>c</category>
      <category>datastructures</category>
      <category>dynamicarrays</category>
      <category>pointers</category>
    </item>
    <item>
      <title>I’m building Blockend</title>
      <dc:creator>Noor ul hassan</dc:creator>
      <pubDate>Wed, 17 Jun 2026 10:03:32 +0000</pubDate>
      <link>https://dev.to/codewithnuh/im-building-blockend-2792</link>
      <guid>https://dev.to/codewithnuh/im-building-blockend-2792</guid>
      <description>&lt;p&gt;Backend development today depends heavily on external libraries for things that are often just reusable patterns — rate limiting, logging, error handling, and similar utilities.&lt;/p&gt;

&lt;p&gt;The issue is not that these libraries are bad. Most of them are well-built and widely used. The real problem is what happens over time: they introduce layers of abstraction between you and your own application. You install them, configure a few options, and move on without ever really seeing what’s happening inside.&lt;/p&gt;

&lt;p&gt;Eventually, your system works, but parts of it are no longer fully visible or easy to reason about.&lt;/p&gt;

&lt;p&gt;Blockend takes a different approach.&lt;/p&gt;

&lt;p&gt;Instead of installing a dependency for these kinds of backend patterns, it brings the actual implementation directly into your project as code. It understands your setup - your framework, your language, your folder structure - and generates clean, readable modules that fit your project naturally.&lt;/p&gt;

&lt;p&gt;There is no black box. Nothing is hidden behind an API surface. The code lives in your repository, and you can read it, modify it, or replace it entirely whenever you want.&lt;/p&gt;

&lt;p&gt;The goal is simple: reduce unnecessary dependencies and bring backend logic back into the open, where it is easier to understand, debug, and control.&lt;/p&gt;

&lt;p&gt;I’m actively building this in public. Feedback is welcome.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/codewithnuh/blockend" rel="noopener noreferrer"&gt;https://github.com/codewithnuh/blockend&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Building JobTracker: A Straightforward Job Application Tracker</title>
      <dc:creator>Noor ul hassan</dc:creator>
      <pubDate>Sat, 18 Apr 2026 09:11:13 +0000</pubDate>
      <link>https://dev.to/codewithnuh/building-jobtracker-a-straightforward-job-application-tracker-24f7</link>
      <guid>https://dev.to/codewithnuh/building-jobtracker-a-straightforward-job-application-tracker-24f7</guid>
      <description>&lt;p&gt;Job hunting turns chaotic real quick. Tabs everywhere, emails you lose track of, and spreadsheets that get outdated the second you close them. Most trackers either throw too many features at you or hide the useful stuff behind paywalls.&lt;/p&gt;

&lt;p&gt;I built JobTracker to fix exactly that mess.&lt;/p&gt;

&lt;p&gt;It gives you a clean 7-stage pipeline: Applied, Screening, Interview, Offer, Accepted — plus Rejected and Withdrawn as separate paths. Every time you change status, it automatically logs the change with a timestamp. You can add company details, role, salary range, and the original job link. There are also basic metrics showing interview rate and offer rate.&lt;/p&gt;

&lt;p&gt;The app is live and free for core tracking here:&lt;br&gt;&lt;br&gt;
&lt;a href="https://job-tracker.noorulhassan.com" rel="noopener noreferrer"&gt;https://job-tracker.noorulhassan.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I built the frontend with Next.js 15 App Router, Tailwind CSS, shadcn/ui, and SWR for data fetching. Backend runs on Fastify with full TypeScript, Drizzle ORM on PostgreSQL, and Zod for strict validation. Authentication uses httpOnly JWT cookies with rate limiting.&lt;/p&gt;

&lt;p&gt;One thing I made sure of is a proper status state machine so you can't make invalid jumps between stages.&lt;/p&gt;

&lt;p&gt;Here's how the transitions look in code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;validTransitions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ApplicationStatus&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ApplicationStatus&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;APPLIED&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SCREENING&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="s1"&gt;REJECTED&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="s1"&gt;WITHDRAWN&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;SCREENING&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;INTERVIEW&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="s1"&gt;REJECTED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;INTERVIEW&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;OFFER&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="s1"&gt;REJECTED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;OFFER&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ACCEPTED&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="s1"&gt;REJECTED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;validTransitions&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;currentStatus&lt;/span&gt;&lt;span class="p"&gt;]?.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newStatus&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Invalid transition: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;currentStatus&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;newStatus&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The full source is open on GitHub:&lt;/p&gt;

&lt;p&gt;Frontend: &lt;a href="https://github.com/codewithnuh/job-tracker" rel="noopener noreferrer"&gt;https://github.com/codewithnuh/job-tracker&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Backend API: &lt;a href="https://github.com/codewithnuh/job-tracker-api" rel="noopener noreferrer"&gt;https://github.com/codewithnuh/job-tracker-api&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're job hunting right now, try the live app. It might actually keep things organized without the usual headache.&lt;/p&gt;

&lt;p&gt;If you're a developer, open the repos and take a look. The code uses strict TypeScript, validation at the edges, and keeps things separated properly.&lt;/p&gt;

&lt;p&gt;Star both repositories if the tool helps you or if the code looks solid. It helps the project reach more people and gives me real feedback on what to improve.&lt;/p&gt;

&lt;p&gt;Follow my GitHub at github.com/codewithnuh for more projects like this.&lt;/p&gt;

&lt;p&gt;What's the biggest pain you face when tracking job applications? Tell me in the comments.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>javascript</category>
      <category>nextjs</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Building Free, High-Performance GSAP Components for the Community</title>
      <dc:creator>Noor ul hassan</dc:creator>
      <pubDate>Wed, 11 Mar 2026 07:39:45 +0000</pubDate>
      <link>https://dev.to/codewithnuh/building-free-high-performance-gsap-components-for-the-community-3n80</link>
      <guid>https://dev.to/codewithnuh/building-free-high-performance-gsap-components-for-the-community-3n80</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%2Frwl5jgx0lvd950hvwi22.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%2Frwl5jgx0lvd950hvwi22.png" alt="Picture of custom cursor component" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As developers, we’re surrounded by component libraries tailored to frameworks like React, Vue, and Angular. They’re great, but they often prioritize functionality over performance, interactivity, or visual flair. That’s why I’ve set out on a mission: &lt;strong&gt;to build unique, highly performant, and visually engaging components using GSAP—and provide them free for the community.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GSAP (GreenSock Animation Platform) is an incredibly powerful animation library, but surprisingly few developers leverage it for reusable UI components. My goal is to change that: to craft components that aren’t just visually impressive, but also optimized for real-world performance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why GSAP Components?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Performance-First:&lt;/strong&gt; GSAP’s &lt;code&gt;quickTo()&lt;/code&gt; and &lt;code&gt;gsap.ticker&lt;/code&gt; allow near-zero per-frame overhead, keeping animations buttery smooth, even in complex UIs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unique Interactivity:&lt;/strong&gt; Components can respond in rich, tactile ways—hover states, click states, magnetic effects, and more.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Framework-Agnostic:&lt;/strong&gt; While many components are framework-specific, GSAP’s animation engine allows me to create truly reusable, high-performance elements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community-Focused:&lt;/strong&gt; Every component will be open-source and free, ready to plug into your projects.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My First Component: A Custom Cursor
&lt;/h2&gt;

&lt;p&gt;I kicked things off with a &lt;strong&gt;high-performance Custom Cursor&lt;/strong&gt;. Instead of the default browser cursor, this component introduces a fluid, dual-element pointer—a small dot and a ring—that reacts dynamically to user interactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Performance-Optimized:&lt;/strong&gt; Uses &lt;code&gt;gsap.quickTo()&lt;/code&gt; for instant response without taxing the frame budget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State Machine:&lt;/strong&gt; Handles default, hover, click, hover-click, and hidden states.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Smart Delegation:&lt;/strong&gt; A single document-level listener manages hover detection, avoiding dozens of individual event listeners.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Touch-Friendly:&lt;/strong&gt; Automatically disables on touch devices.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Always Visible:&lt;/strong&gt; Uses &lt;code&gt;mix-blend-difference&lt;/code&gt; so the cursor stands out against any background.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can try it live here: &lt;a href="https://codewithnuh.vercel.app/labs/custom-cursor" rel="noopener noreferrer"&gt;Custom Cursor Demo&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Implementation Overview
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install Dependencies&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;gsap tailwindcss
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Create the Component&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Place logic in &lt;code&gt;components/ui/CustomCursor.tsx&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Disable the native cursor globally in CSS:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;gsap.quickTo()&lt;/code&gt; for smooth motion and &lt;code&gt;gsap.ticker&lt;/code&gt; to update the cursor position efficiently.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Use Globally&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Import &lt;code&gt;&amp;lt;CustomCursor /&amp;gt;&lt;/code&gt; in your root layout:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;CustomCursor&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@/components/ui/CustomCursor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;RootLayout&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;CustomCursor&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Make Elements Interactive&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Add &lt;code&gt;data-cursor="hover"&lt;/code&gt; to trigger the hover state:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;data-cursor&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"hover"&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"px-6 py-2 bg-white text-black rounded-full"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  Hover Me
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Performance Notes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ref-based positioning:&lt;/strong&gt; Mouse coordinates and GSAP quickTo functions are stored in refs to prevent unnecessary React re-renders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GPU-Accelerated Animations:&lt;/strong&gt; Using &lt;code&gt;will-change: transform&lt;/code&gt; ensures smooth, hardware-accelerated movement.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ticker Sync:&lt;/strong&gt; GSAP ticker avoids conflicts with React render cycles, keeping animations fluid.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;This is just the beginning. My plan is to build a library of &lt;strong&gt;free GSAP components&lt;/strong&gt; that are not only visually stunning but also &lt;strong&gt;lightweight, interactive, and easy to integrate&lt;/strong&gt;. From dynamic cursors to scroll-triggered animations and beyond, my goal is to give developers tools they won’t find anywhere else—without charging a cent.&lt;/p&gt;

&lt;p&gt;If you’re curious or want to contribute, check out the first demo here: &lt;a href="https://codewithnuh.vercel.app/labs/custom-cursor" rel="noopener noreferrer"&gt;Custom Cursor Live&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stay tuned—more components are coming soon!&lt;/strong&gt;&lt;/p&gt;




</description>
      <category>gsap</category>
      <category>animation</category>
      <category>react</category>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>Why Do Clicks “Stack Up” When JavaScript Blocks the UI?</title>
      <dc:creator>Noor ul hassan</dc:creator>
      <pubDate>Mon, 23 Feb 2026 06:19:15 +0000</pubDate>
      <link>https://dev.to/codewithnuh/why-do-clicks-stack-up-when-javascript-blocks-the-ui-4n3k</link>
      <guid>https://dev.to/codewithnuh/why-do-clicks-stack-up-when-javascript-blocks-the-ui-4n3k</guid>
      <description>&lt;p&gt;I recently noticed something interesting while experimenting with JavaScript.&lt;/p&gt;

&lt;p&gt;I wrote a simple synchronous loop that runs for about 10 seconds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Block for 10 seconds&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During those 10 seconds, the UI completely freezes. That part makes sense.&lt;/p&gt;

&lt;p&gt;But here’s the interesting part:&lt;/p&gt;

&lt;p&gt;While the loop was running, I kept clicking a button on the page. Nothing happened. No console logs. No UI updates.&lt;/p&gt;

&lt;p&gt;Then the loop finished…&lt;/p&gt;

&lt;p&gt;And suddenly, all my clicks fired at once.&lt;/p&gt;

&lt;p&gt;It felt like the browser had “saved” them somewhere.&lt;/p&gt;

&lt;p&gt;So what’s actually happening?&lt;/p&gt;




&lt;h2&gt;
  
  
  The Short Answer: OS Input Buffering
&lt;/h2&gt;

&lt;p&gt;When JavaScript runs a heavy synchronous task, the &lt;strong&gt;main thread (Call Stack)&lt;/strong&gt; is blocked.&lt;/p&gt;

&lt;p&gt;But JavaScript freezing does not mean your entire system freezes.&lt;/p&gt;

&lt;p&gt;Let’s break it down:&lt;/p&gt;

&lt;h3&gt;
  
  
  1️ Hardware Level
&lt;/h3&gt;

&lt;p&gt;When you click your mouse, the hardware sends an interrupt signal to the Operating System.&lt;/p&gt;

&lt;h3&gt;
  
  
  2️ OS Level
&lt;/h3&gt;

&lt;p&gt;The OS records that click in its input buffer.&lt;br&gt;
Even if your browser tab is busy, the OS is still fully operational.&lt;/p&gt;

&lt;h3&gt;
  
  
  3️ Browser Level
&lt;/h3&gt;

&lt;p&gt;The browser receives those events from the OS and places them into the &lt;strong&gt;Macrotask Queue&lt;/strong&gt; (also called the Callback Queue).&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Do They Execute After the Loop?
&lt;/h2&gt;

&lt;p&gt;The Event Loop cannot check the Macrotask Queue until the Call Stack is empty.&lt;/p&gt;

&lt;p&gt;During the 10-second loop:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Call Stack is busy.&lt;/li&gt;
&lt;li&gt;The Event Loop is stuck.&lt;/li&gt;
&lt;li&gt;It literally cannot move to the next “tick” to process events.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After the loop finishes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Call Stack clears.&lt;/li&gt;
&lt;li&gt;The Event Loop runs again.&lt;/li&gt;
&lt;li&gt;It sees all the queued click events.&lt;/li&gt;
&lt;li&gt;It processes them one by one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s why everything fires at once.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Big Insight
&lt;/h2&gt;

&lt;p&gt;JavaScript is single-threaded.&lt;/p&gt;

&lt;p&gt;But your Operating System is not.&lt;/p&gt;

&lt;p&gt;Even when your JavaScript is frozen, the OS is still collecting user input and handing it to the browser.&lt;/p&gt;

&lt;p&gt;The browser politely queues those events until JavaScript is ready again.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Matters
&lt;/h2&gt;

&lt;p&gt;Understanding this helps explain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Why heavy synchronous code freezes the UI&lt;/li&gt;
&lt;li&gt;Why clicks seem to “stack up”&lt;/li&gt;
&lt;li&gt;Why long-running tasks should be avoided on the main thread&lt;/li&gt;
&lt;li&gt;Why Web Workers exist&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also makes the Event Loop feel less magical and more mechanical.&lt;/p&gt;

&lt;p&gt;Sometimes weird UI behavior isn’t magic — it’s just how the system is designed.&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%2Fjatbzxy541jz5h0r3mi1.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%2Fjatbzxy541jz5h0r3mi1.gif" alt="GIF demonstrates when UI blocked but over events are buffered by OS " width="460" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Tailwind A11y Checker 🌊♿ — Stop shipping inaccessible UIs by accident</title>
      <dc:creator>Noor ul hassan</dc:creator>
      <pubDate>Mon, 09 Feb 2026 14:40:09 +0000</pubDate>
      <link>https://dev.to/codewithnuh/tailwind-a11y-checker-stop-shipping-inaccessible-uis-by-accident-16i3</link>
      <guid>https://dev.to/codewithnuh/tailwind-a11y-checker-stop-shipping-inaccessible-uis-by-accident-16i3</guid>
      <description>&lt;p&gt;Real talk: I used to think "accessibility" meant running Lighthouse before deploy. Then a user emailed me saying they couldn't read half my app because the contrast was garbage.  &lt;/p&gt;

&lt;p&gt;Turns out &lt;code&gt;bg-blue-500&lt;/code&gt; + &lt;code&gt;text-blue-600&lt;/code&gt; looks "clean" but fails WCAG hard. And I'd shipped that combo everywhere.  &lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;Tailwind A11y Checker&lt;/strong&gt; — a VS Code extension that catches these mistakes &lt;em&gt;while you code&lt;/em&gt;:  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it actually does:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Real-time contrast checks&lt;/strong&gt; — Flags unreadable text combos and shows the exact WCAG ratio&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;One-click fixes&lt;/strong&gt; — Suggests the closest Tailwind shade that actually passes (no more guessing &lt;code&gt;blue-700&lt;/code&gt; vs &lt;code&gt;blue-800&lt;/code&gt;)&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Focus state reminders&lt;/strong&gt; — Yells at you if your button has no &lt;code&gt;focus:&lt;/code&gt; classes (keyboard users will thank you)  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Works everywhere:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;.html&lt;/code&gt; • &lt;code&gt;.jsx&lt;/code&gt;/&lt;code&gt;.tsx&lt;/code&gt; • &lt;code&gt;.vue&lt;/code&gt; • &lt;code&gt;.svelte&lt;/code&gt; • &lt;code&gt;.js&lt;/code&gt;/&lt;code&gt;.ts&lt;/code&gt;  &lt;/p&gt;

&lt;p&gt;No setup. No config. Just install and your editor starts keeping you honest.  &lt;/p&gt;

&lt;p&gt;👉 Grab it: &lt;a href="https://marketplace.visualstudio.com/items?itemName=codewithnuh.tailwind-a11y-checker" rel="noopener noreferrer"&gt;VS Code Marketplace&lt;/a&gt;&lt;br&gt;&lt;br&gt;
👉 Found a false positive? Open an issue — I'm actively tweaking the rules&lt;br&gt;&lt;br&gt;
👉 Using a custom color palette? Let me know — planning to add support  &lt;/p&gt;

&lt;p&gt;Built this because I kept failing basic a11y checks. Figured if it helps me, it might help you too.  &lt;/p&gt;

&lt;p&gt;Made with ❤️ by codewithnuh&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>tailwindcss</category>
      <category>webdev</category>
      <category>a11y</category>
    </item>
    <item>
      <title>Peeking Behind the Scenes: How Python Makes Your Code Come Alive!</title>
      <dc:creator>Noor ul hassan</dc:creator>
      <pubDate>Sat, 29 Mar 2025 10:33:33 +0000</pubDate>
      <link>https://dev.to/codewithnuh/peeking-behind-the-scenes-how-python-makes-your-code-come-alive-2joo</link>
      <guid>https://dev.to/codewithnuh/peeking-behind-the-scenes-how-python-makes-your-code-come-alive-2joo</guid>
      <description>&lt;p&gt;Python! You've probably heard it's super easy to read and use. But have you ever wondered what happens behind the scenes when you type in some Python code and hit run? It's actually a pretty cool process where Python works its magic to bring your program to life! Even when you run a simple program from the command line, there's a fascinating journey your code takes.&lt;/p&gt;

&lt;p&gt;While Python is known as an "interpreted" language, meaning it runs your code line by line, there's a sneaky little intermediate step involved. This article will take you on a tour of how Python actually executes your code, shining a light on the roles of the &lt;strong&gt;interpreter&lt;/strong&gt;, a kind of "secret code" called &lt;strong&gt;bytecode&lt;/strong&gt;, and the &lt;strong&gt;Python Virtual Machine (PVM)&lt;/strong&gt; – think of it as the stage where your code performs!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Meet the Python Interpreter: Your Code's Best Friend&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you type &lt;code&gt;python your_script.py&lt;/code&gt; in your terminal, you're calling on the &lt;strong&gt;Python interpreter&lt;/strong&gt;. Think of it as the 'official' guide that knows how to read, understand, and ultimately run your Python instructions. The most common version of this guide is called &lt;strong&gt;CPython&lt;/strong&gt;, and it's written in a programming language called C. There are other versions out there, like Jython (for running Python on Java systems) and IronPython (for Windows systems), but for our adventure today, we'll stick with CPython, as it's the one you're most likely to bump into.&lt;/p&gt;

&lt;p&gt;The interpreter's first job is to take a peek at your Python source code file (that's your &lt;code&gt;your_script.py&lt;/code&gt; file). Now, unlike some other programming languages like C++ or Java that get translated directly into a language your computer's processor understands, Python takes a slightly different path.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Turning Your Code into a Secret Code: Bytecode!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before your code actually runs, CPython does a quick translation. But it doesn't translate it into your computer's specific language. Instead, Python turns your original code into an intermediate code called &lt;strong&gt;bytecode&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Think of bytecode as a secret code that the Python interpreter understands. It's like a translator has already done some of the work, making it easier for the interpreter to follow your instructions. This "secret code" is also special because it can run on any computer that speaks Python!&lt;/p&gt;

&lt;p&gt;This translation to bytecode happens automatically in the background. Have you ever seen files ending in &lt;code&gt;.pyc&lt;/code&gt; in your Python projects? Those are the saved versions of this bytecode for your Python programs. Python creates them to make running the same program faster next time. If you haven't changed your code since the last run, Python can just load up the bytecode from the &lt;code&gt;.pyc&lt;/code&gt; file and skip the translation step. Pretty neat, huh?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sneak Peek at the Secret Code!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Python even lets you peek at this "secret code" using a tool called the &lt;code&gt;dis&lt;/code&gt; module (short for disassembler). Let's say you have a simple function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can see its bytecode by doing this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dis&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;

&lt;span class="n"&gt;dis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you run this, you'll see something like this (don't worry if the exact details look a little different on your computer):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  2           0 LOAD_FAST                0 (a)
              2 LOAD_FAST                1 (b)
              4 BINARY_ADD
              6 RETURN_VALUE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This might look a bit strange, but it's basically the low-level instructions that tell the Python interpreter to: grab the values of &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;, perform the addition, and then give back the result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Python Virtual Machine (PVM): Where the Magic Happens!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once your code is in bytecode "secret code", the next important player steps onto the stage: the &lt;strong&gt;Python Virtual Machine&lt;/strong&gt;, or &lt;strong&gt;PVM&lt;/strong&gt; for short. Now, don't let the name "machine" confuse you – it's not a physical piece of hardware like your computer. Instead, the PVM is like a software program that pretends to be a computer, specifically designed to understand and run that bytecode.&lt;/p&gt;

&lt;p&gt;The PVM's main job is to take those bytecode instructions and actually make them happen! It does this by following a simple process, kind of like a little dance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fetch:&lt;/strong&gt; It grabs the next instruction from the bytecode.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decode:&lt;/strong&gt; It figures out what that instruction means.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Execute:&lt;/strong&gt; It performs the action that the instruction tells it to do.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This "fetch-decode-execute" dance keeps going until all the bytecode instructions have been processed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Watch a Simple Program Run!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's follow along as Python runs a super simple program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# hello.py
&lt;/span&gt;&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello, World!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what happens when you type &lt;code&gt;python hello.py&lt;/code&gt; in your terminal:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Invocation:&lt;/strong&gt; You tell Python to run your &lt;code&gt;hello.py&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Interpreter Startup:&lt;/strong&gt; The CPython interpreter wakes up and gets ready.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Code Reading:&lt;/strong&gt; The interpreter takes a look at your &lt;code&gt;hello.py&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Compilation to Bytecode:&lt;/strong&gt; Python translates your &lt;code&gt;print("Hello, World!")&lt;/code&gt; line into its "secret code". This code basically tells the PVM: "Hey, show the words 'Hello, World!' on the screen." This bytecode might be quickly stored in memory or maybe even saved in a &lt;code&gt;hello.pyc&lt;/code&gt; file (depending on your settings and Python version).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;PVM Execution:&lt;/strong&gt; Now it's the PVM's turn!

&lt;ul&gt;
&lt;li&gt;It reads the first instruction: "Load the words 'Hello, World!'".&lt;/li&gt;
&lt;li&gt;Then it reads the next instruction: "Call the &lt;code&gt;print&lt;/code&gt; function".&lt;/li&gt;
&lt;li&gt;Finally, it acts on this instruction, telling your computer's operating system to display "Hello, World!" on your screen.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Program Termination:&lt;/strong&gt; Once the PVM has followed all the instructions, it finishes its job, and the Python interpreter goes back to sleep.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;A Quick Look at Memory: Where Does Everything Go?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, before we wrap up, let's touch on something else that's happening behind the scenes: how Python handles memory. Imagine Python has a big storage room (the &lt;strong&gt;heap&lt;/strong&gt;) where it keeps all the "things" your program creates, like our "Hello, World!" string. Python is also tidy and has a "garbage collector" that automatically cleans up things that are no longer needed, so the storage room doesn't get too cluttered. One of the ways Python keeps track of what's being used is called &lt;strong&gt;reference counting&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wrapping Up: Python's Behind-the-Scenes Magic&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, even running a simple Python program involves a neat process happening under the hood. The Python interpreter is like the director, first translating your code into a platform-friendly "secret code" called bytecode. Then, the Python Virtual Machine acts as the stage crew, diligently following those instructions to bring your program to life on your screen. Understanding this basic process gives you a cool peek into how Python works and can even help you when you're trying to figure out why your code might be doing something unexpected. While we looked at a very simple program, the same fundamental steps happen even with much more complex Python projects, showing just how clever and efficient Python is!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Advanced JavaScript Concepts Every Developer Should Know</title>
      <dc:creator>Noor ul hassan</dc:creator>
      <pubDate>Tue, 24 Sep 2024 10:21:22 +0000</pubDate>
      <link>https://dev.to/codewithnuh/advanced-javascript-concepts-every-developer-should-know-jee</link>
      <guid>https://dev.to/codewithnuh/advanced-javascript-concepts-every-developer-should-know-jee</guid>
      <description>&lt;p&gt;JavaScript is a language that many developers use daily, but there are numerous hidden gems within its ecosystem that even experienced developers may not be familiar with. This article explores some lesser-known JavaScript concepts that can significantly enhance your programming skills. We’ll cover concepts like &lt;strong&gt;Proxies&lt;/strong&gt;, &lt;strong&gt;Symbols&lt;/strong&gt;, &lt;strong&gt;Generators&lt;/strong&gt;, and more, demonstrating each with examples and solving problems to illustrate their power. &lt;/p&gt;

&lt;p&gt;By the end, you'll have a deeper understanding of JavaScript and know when (and when not) to use these advanced features.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. &lt;strong&gt;Proxies&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What are Proxies?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Proxy in JavaScript allows you to intercept and customize fundamental operations like property lookups, assignments, and function invocations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Imagine you're building a system where users have objects that track their actions. Instead of modifying every part of your app to track property access, you can use a Proxy to intercept and log these actions.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;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;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prop&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;`Property '&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;' was accessed`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Property &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; doesn't exist`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userProxy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Proxy&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;handler&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userProxy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Logs: Property 'name' was accessed, Returns: Alice&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;userProxy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Logs: Property 'address' was accessed, Returns: Property address doesn't exist&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Allows you to handle and intercept almost any interaction with an object.&lt;/li&gt;
&lt;li&gt;Great for logging, validation, and dynamic behavior.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can introduce performance overhead if overused.&lt;/li&gt;
&lt;li&gt;Harder to debug due to the abstraction layer between your logic and object behavior.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. &lt;strong&gt;Symbols&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What are Symbols?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Symbols are a new primitive type introduced in ES6. They provide unique keys for object properties, making them useful when you need to avoid property name collisions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Let’s say you’re working on an object that integrates with third-party code, and you want to add custom properties without overwriting their keys.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;uniqueId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Symbol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;uniqueId&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="mi"&gt;123&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;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;uniqueId&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// 123&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;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&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="c1"&gt;// ['name'] - Symbol key is hidden from iteration&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Symbols are unique, even if they share the same description.&lt;/li&gt;
&lt;li&gt;Prevents accidental property overwrites, making them ideal for use in libraries or API design.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Symbols are not enumerable, which can make debugging or iteration slightly trickier.&lt;/li&gt;
&lt;li&gt;Can reduce code readability if overused.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  3. &lt;strong&gt;Generator Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What are Generators?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Generators are functions that can be paused and resumed, making them useful for managing async flows or producing data on demand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Suppose you want to generate a sequence of Fibonacci numbers. Instead of generating the entire sequence up front, you can create a generator that yields values one by one, allowing lazy evaluation.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fib&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 0&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;fib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 1&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;fib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 1&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;fib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Efficient for generating sequences where you only need a few values at a time.&lt;/li&gt;
&lt;li&gt;Allows for cleaner async flows when used with &lt;code&gt;yield&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Not as commonly used as Promises or &lt;code&gt;async/await&lt;/code&gt;, so they have a steeper learning curve.&lt;/li&gt;
&lt;li&gt;Can lead to complex code if overused.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  4. &lt;strong&gt;Tagged Template Literals&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What are Tagged Template Literals?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Tagged templates allow you to process template literals with a function, making them incredibly powerful for building DSLs (domain-specific languages) like CSS-in-JS libraries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; You need to build a template system that processes user input and sanitizes it to avoid XSS attacks.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;safeHTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;strings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;strings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;acc&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;escapeHTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;values&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;escapeHTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&amp;amp;/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;amp;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&amp;lt;/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&amp;gt;/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userInput&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;script&amp;gt;alert('XSS')&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;safeHTML&lt;/span&gt;&lt;span class="s2"&gt;`User said: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;userInput&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;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;output&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// User said: &amp;amp;lt;script&amp;amp;gt;alert('XSS')&amp;amp;lt;/script&amp;amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Allows for fine control over string interpolation.&lt;/li&gt;
&lt;li&gt;Great for building libraries that require string parsing or transformation (e.g., CSS, SQL queries).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Not commonly needed unless working with specific libraries or creating your own.&lt;/li&gt;
&lt;li&gt;Can be difficult to understand and debug for beginners.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  5. &lt;strong&gt;WeakMaps and WeakSets&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What are WeakMaps and WeakSets?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;WeakMaps are collections of key-value pairs where the keys are weakly referenced. This means if no other references to the key exist, the entry is garbage collected.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; You’re building a caching system, and you want to ensure that once objects are no longer needed, they are automatically garbage collected to free up memory.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="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;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;weakCache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;WeakMap&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;weakCache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cached data&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;weakCache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Cached data&lt;/span&gt;

&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// The entry in weakCache will be garbage collected&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automatic garbage collection of entries, preventing memory leaks.&lt;/li&gt;
&lt;li&gt;Ideal for caching where object lifetimes are uncertain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WeakMaps are not enumerable, making them difficult to iterate over.&lt;/li&gt;
&lt;li&gt;Limited to only objects as keys.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  6. &lt;strong&gt;Currying&lt;/strong&gt;
&lt;/h3&gt;

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

&lt;p&gt;Currying transforms a function that takes multiple arguments into a sequence of functions that each take a single argument. It’s a functional programming technique that can increase code flexibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Let’s say you have a function that applies a discount based on a percentage. You want to reuse this function with different percentages throughout your app.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;applyDiscount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;discount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;price&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;discount&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tenPercentOff&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;applyDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;twentyPercentOff&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;applyDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&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;tenPercentOff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 90&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;twentyPercentOff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// 80&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can make functions more reusable by pre-applying arguments.&lt;/li&gt;
&lt;li&gt;Allows you to easily create partial applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Not intuitive for developers unfamiliar with functional programming.&lt;/li&gt;
&lt;li&gt;Can lead to overly complex code if used excessively.&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;Each of these advanced JavaScript concepts — Proxies, Symbols, Generators, Tagged Template Literals, WeakMaps, and Currying — offers unique capabilities to solve specific problems in more efficient, scalable, or elegant ways. However, they come with trade-offs, such as increased complexity or potential performance issues.&lt;/p&gt;

&lt;p&gt;The key takeaway is to &lt;strong&gt;understand when and where to use these concepts&lt;/strong&gt;. Just because they exist doesn’t mean you should use them in every project. Instead, incorporate them when they provide clear benefits, like improving code readability, performance, or flexibility.&lt;/p&gt;

&lt;p&gt;By exploring these advanced techniques, you’ll be able to tackle more sophisticated problems and write more powerful JavaScript.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title># Learning JavaScript: A Beginner's Guide</title>
      <dc:creator>Noor ul hassan</dc:creator>
      <pubDate>Sat, 12 Aug 2023 13:09:00 +0000</pubDate>
      <link>https://dev.to/codewithnuh/-learning-javascript-a-beginners-guide-1a2g</link>
      <guid>https://dev.to/codewithnuh/-learning-javascript-a-beginners-guide-1a2g</guid>
      <description>&lt;p&gt;JavaScript is a versatile and widely used programming language that powers the interactive and dynamic elements of websites. Whether you're looking to enhance your web development skills or dive into programming for the first time, learning JavaScript can be a rewarding journey. In this guide, we'll walk you through the steps to learn JavaScript effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. Set Up Your Environment&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Before you begin, ensure you have a text editor for writing code. Popular choices include Visual Studio Code, Sublime Text, and Atom. You'll also need a web browser for testing your JavaScript code.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Understand the Basics&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Start by grasping fundamental concepts like variables, data types (numbers, strings, booleans), and basic operations (arithmetic, concatenation). This foundation will help you understand more complex topics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Concepts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3. Control Structures&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Learn about control structures such as &lt;code&gt;if&lt;/code&gt; statements, &lt;code&gt;for&lt;/code&gt; loops, and &lt;code&gt;while&lt;/code&gt; loops. These structures allow you to make decisions and repeat actions based on conditions.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4. Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Functions are blocks of code that can be reused. Master how to create, call, and pass parameters to functions. Understanding functions is crucial for building organized and efficient code.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;5. Objects and Arrays&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;JavaScript objects and arrays are used to store and organize data. Explore how to create and manipulate objects and arrays to manage information effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deepening Your Knowledge
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;6. DOM Manipulation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The Document Object Model (DOM) allows you to interact with web pages. Learn how to use JavaScript to modify HTML and CSS, enabling dynamic and responsive web experiences.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;7. Events and Event Handling&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Understand how to detect and respond to user actions like clicks and keyboard input. Event handling is vital for creating interactive web applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;8. Asynchronous JavaScript&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Explore asynchronous programming with concepts like callbacks, promises, and async/await. This is crucial for handling tasks that don't need to happen in a specific order, like fetching data from a server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Projects
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;9. Build Simple Projects&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Apply your knowledge by building small projects. Create interactive forms, a to-do list, or a basic calculator. Practical projects help solidify your understanding and boost your confidence.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;10. Work on Real-world Projects&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;As you become more comfortable with JavaScript, take on more complex projects. Build a portfolio website, a weather app that fetches data, or a simple game. Real-world projects showcase your skills and provide tangible results.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learning Resources
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;11. Online Tutorials and Courses&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Numerous online platforms offer JavaScript tutorials and courses, catering to different learning styles. Check out resources like Codecademy, freeCodeCamp, and MDN Web Docs.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;12. Books and Documentation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Books like "Eloquent JavaScript" by Marijn Haverbeke and the Mozilla Developer Network (MDN) JavaScript Guide provide in-depth explanations and examples.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;13. Practice, Practice, Practice&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Consistent practice is key. Work on coding challenges from websites like LeetCode and HackerRank to reinforce your skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Learning JavaScript can be a rewarding endeavor that opens up countless opportunities in web development. Approach your learning journey with patience, curiosity, and a willingness to tackle challenges. Remember that programming is a skill that improves over time, so keep coding and experimenting to become a proficient JavaScript developer.# Learning JavaScript: A Beginner's Guide&lt;/p&gt;

&lt;p&gt;JavaScript is a versatile and widely used programming language that powers the interactive and dynamic elements of websites. Whether you're looking to enhance your web development skills or dive into programming for the first time, learning JavaScript can be a rewarding journey. In this guide, we'll walk you through the steps to learn JavaScript effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. Set Up Your Environment&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Before you begin, ensure you have a text editor for writing code. Popular choices include Visual Studio Code, Sublime Text, and Atom. You'll also need a web browser for testing your JavaScript code.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;2. Understand the Basics&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Start by grasping fundamental concepts like variables, data types (numbers, strings, booleans), and basic operations (arithmetic, concatenation). This foundation will help you understand more complex topics.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Concepts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;3. Control Structures&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Learn about control structures such as &lt;code&gt;if&lt;/code&gt; statements, &lt;code&gt;for&lt;/code&gt; loops, and &lt;code&gt;while&lt;/code&gt; loops. These structures allow you to make decisions and repeat actions based on conditions.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;4. Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Functions are blocks of code that can be reused. Master how to create, call, and pass parameters to functions. Understanding functions is crucial for building organized and efficient code.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;5. Objects and Arrays&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;JavaScript objects and arrays are used to store and organize data. Explore how to create and manipulate objects and arrays to manage information effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deepening Your Knowledge
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;6. DOM Manipulation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The Document Object Model (DOM) allows you to interact with web pages. Learn how to use JavaScript to modify HTML and CSS, enabling dynamic and responsive web experiences.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;7. Events and Event Handling&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Understand how to detect and respond to user actions like clicks and keyboard input. Event handling is vital for creating interactive web applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;8. Asynchronous JavaScript&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Explore asynchronous programming with concepts like callbacks, promises, and async/await. This is crucial for handling tasks that don't need to happen in a specific order, like fetching data from a server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Projects
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;9. Build Simple Projects&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Apply your knowledge by building small projects. Create interactive forms, a to-do list, or a basic calculator. Practical projects help solidify your understanding and boost your confidence.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;10. Work on Real-world Projects&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;As you become more comfortable with JavaScript, take on more complex projects. Build a portfolio website, a weather app that fetches data, or a simple game. Real-world projects showcase your skills and provide tangible results.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learning Resources
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;11. Online Tutorials and Courses&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Numerous online platforms offer JavaScript tutorials and courses, catering to different learning styles. Check out resources like Codecademy, freeCodeCamp, and MDN Web Docs.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;12. Books and Documentation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Books like "Eloquent JavaScript" by Marijn Haverbeke and the Mozilla Developer Network (MDN) JavaScript Guide provide in-depth explanations and examples.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;13. Practice, Practice, Practice&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Consistent practice is key. Work on coding challenges from websites like LeetCode and HackerRank to reinforce your skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Learning JavaScript can be a rewarding endeavor that opens up countless opportunities in web development. Approach your learning journey with patience, curiosity, and a willingness to tackle challenges. Remember that programming is a skill that improves over time, so keep coding and experimenting to become a proficient JavaScript developer.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>roadmap</category>
    </item>
  </channel>
</rss>
