<?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: Sanu Khan</title>
    <description>The latest articles on DEV Community by Sanu Khan (@sanukhandev).</description>
    <link>https://dev.to/sanukhandev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F452763%2F3b27590d-0ec0-4286-81fb-7123984ce22e.jpg</url>
      <title>DEV Community: Sanu Khan</title>
      <link>https://dev.to/sanukhandev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sanukhandev"/>
    <language>en</language>
    <item>
      <title>API Gateway: The Bouncer Your Microservices Didn’t Know They Needed</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Wed, 24 Dec 2025 07:45:34 +0000</pubDate>
      <link>https://dev.to/sanukhandev/api-gateway-the-bouncer-your-microservices-didnt-know-they-needed-1j0e</link>
      <guid>https://dev.to/sanukhandev/api-gateway-the-bouncer-your-microservices-didnt-know-they-needed-1j0e</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%2Fkplhckq5vy9094mv3iet.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%2Fkplhckq5vy9094mv3iet.png" alt="Why api Gateway" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  API Gateway: The Bouncer at the Club Called “Your Backend”
&lt;/h2&gt;

&lt;p&gt;If your system is a party, your microservices are the guests, and your clients are… well… clients.&lt;br&gt;&lt;br&gt;
An &lt;strong&gt;API Gateway&lt;/strong&gt; is the &lt;strong&gt;one person at the entrance&lt;/strong&gt; who checks IDs, controls the crowd, directs people to the right room, and occasionally stops someone from setting the place on fire.&lt;/p&gt;

&lt;p&gt;Without a gateway, clients talk to services directly. Which sounds “simple” until you realize you’ve just invited everyone to wander into your kitchen and argue with your fridge.&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%2Fydo6jmpc3dmbh1a7dxcl.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%2Fydo6jmpc3dmbh1a7dxcl.png" alt="Client -&amp;gt; API Gateway -&amp;gt; Services" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What an API Gateway actually does (besides looking important)
&lt;/h2&gt;

&lt;p&gt;An API Gateway is a &lt;strong&gt;single entry point&lt;/strong&gt; for external requests. It sits in front of your services and handles “common chores” so every service doesn’t have to reinvent them badly.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Greatest Hits (Gateway Edition)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Routing&lt;/strong&gt;: “/orders goes to Orders Service. Obviously.”&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AuthN/AuthZ&lt;/strong&gt;: “Show me your token. No token? No entry.”&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate limiting&lt;/strong&gt;: “You’ve made 10,000 requests in 4 seconds. Please step away.”&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load balancing&lt;/strong&gt;: “Service instance #3 looks tired. Go to #4.”&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching&lt;/strong&gt;: “We already answered this. Here, take the cached response.”&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Aggregation&lt;/strong&gt;: “Client wants one response, backend needs 5 calls. I’ll combine it.”&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protocol translation&lt;/strong&gt;: “Client speaks REST, service speaks gRPC. I’m bilingual.”&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Without a Gateway vs With a Gateway (a short horror story)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Without API Gateway
&lt;/h3&gt;

&lt;p&gt;Clients call multiple services directly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Client must know &lt;strong&gt;every service URL&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Every service needs &lt;strong&gt;its own auth + rate limit + logging&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Changing a service endpoint means &lt;strong&gt;client changes&lt;/strong&gt; (aka “fun”)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  With API Gateway
&lt;/h3&gt;

&lt;p&gt;Clients call one endpoint:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One URL&lt;/strong&gt; to rule them all&lt;/li&gt;
&lt;li&gt;Centralized policies (security, throttling, observability)&lt;/li&gt;
&lt;li&gt;Backend can evolve without breaking clients (mostly)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1kez3ovoxswwm0q43rcp.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%2F1kez3ovoxswwm0q43rcp.png" alt="Chaos vs Calm" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why people love API Gateways (the advantages)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1) Centralized security
&lt;/h3&gt;

&lt;p&gt;You implement authentication/authorization once at the edge—less duplication, fewer inconsistencies, fewer “oops we forgot auth on that endpoint.”&lt;/p&gt;

&lt;h3&gt;
  
  
  2) Simpler clients
&lt;/h3&gt;

&lt;p&gt;Mobile apps, web apps, third-party clients—everyone hits &lt;strong&gt;one&lt;/strong&gt; gateway instead of juggling service endpoints like a circus act.&lt;/p&gt;

&lt;h3&gt;
  
  
  3) Better performance knobs
&lt;/h3&gt;

&lt;p&gt;Caching, compression, request shaping, response aggregation—gateways can reduce total calls and smooth backend load.&lt;/p&gt;

&lt;h3&gt;
  
  
  4) Observability and governance
&lt;/h3&gt;

&lt;p&gt;One place for metrics, logs, tracing correlation, and global policies.&lt;br&gt;&lt;br&gt;
Your monitoring gets less “Where is this failing?” and more “Oh, it’s failing right there.”&lt;/p&gt;

&lt;h3&gt;
  
  
  5) Versioning and compatibility
&lt;/h3&gt;

&lt;p&gt;You can support &lt;code&gt;/v1&lt;/code&gt; and &lt;code&gt;/v2&lt;/code&gt; without forcing every service to carry legacy baggage forever.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why API Gateways can still ruin your week (the disadvantages)
&lt;/h2&gt;

&lt;p&gt;Let’s be honest: adding a gateway is adding a &lt;em&gt;new&lt;/em&gt; thing to break.&lt;/p&gt;

&lt;h3&gt;
  
  
  1) It can be a single point of failure
&lt;/h3&gt;

&lt;p&gt;If the gateway goes down, congratulations—you’ve invented &lt;strong&gt;distributed downtime&lt;/strong&gt;.&lt;br&gt;
Solution: run it HA, multi-zone, scalable, and monitored like it’s your paycheck (because it is).&lt;/p&gt;

&lt;h3&gt;
  
  
  2) Extra latency
&lt;/h3&gt;

&lt;p&gt;It’s another hop. Usually worth it, but it exists.&lt;br&gt;&lt;br&gt;
The fix is good configuration, caching, and not doing “just one more plugin” until it becomes a Christmas tree.&lt;/p&gt;

&lt;h3&gt;
  
  
  3) Config complexity
&lt;/h3&gt;

&lt;p&gt;Route rules, auth policies, transformations, rate limits, plugins—at scale it becomes a discipline, not a weekend task.&lt;/p&gt;

&lt;h3&gt;
  
  
  4) Cost and lock-in
&lt;/h3&gt;

&lt;p&gt;Managed gateways cost money. Self-hosted gateways cost engineers (also money). Some solutions can strongly couple you to a cloud ecosystem.&lt;/p&gt;




&lt;h2&gt;
  
  
  API Gateway vs Load Balancer vs Service Mesh (stop mixing them up)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Load Balancer
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Operates at network level (L4/L7 depending)&lt;/li&gt;
&lt;li&gt;Distributes traffic, doesn’t usually handle API semantics like auth, quotas, transformations&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  API Gateway
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;North–south traffic (clients → services)&lt;/li&gt;
&lt;li&gt;API-focused features: auth, rate limiting, versioning, transformation, aggregation&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Service Mesh
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;East–west traffic (service → service)&lt;/li&gt;
&lt;li&gt;mTLS, retries, circuit breaking, traffic shaping &lt;strong&gt;inside&lt;/strong&gt; your cluster&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They can coexist. In serious systems, they usually do.&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%2Fi7qpvrbsc1e2yy2svvt2.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%2Fi7qpvrbsc1e2yy2svvt2.png" alt="Gateway vs Mesh" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-world examples (so you can name-drop responsibly)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AWS API Gateway&lt;/strong&gt;: Common in serverless setups (API Gateway → Lambda).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kong&lt;/strong&gt;: Popular in Kubernetes and microservices, plugin-driven, highly extensible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NGINX&lt;/strong&gt;: Can be configured as a gateway/reverse proxy with a lot of control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Traefik&lt;/strong&gt;: Cloud-native routing with auto-discovery vibes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pick based on your environment, governance needs, and how much “platform engineering” you want to own.&lt;/p&gt;




&lt;h2&gt;
  
  
  When should you use an API Gateway?
&lt;/h2&gt;

&lt;p&gt;Use one when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have multiple services and multiple clients&lt;/li&gt;
&lt;li&gt;You need centralized security, throttling, and monitoring&lt;/li&gt;
&lt;li&gt;You want a stable external API while internals evolve&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You might skip it when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have a tiny system with one service (for now)&lt;/li&gt;
&lt;li&gt;You don’t need cross-cutting policies yet&lt;/li&gt;
&lt;li&gt;You’re allergic to operating infrastructure (fair)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  A practical mental model (that won’t betray you in interviews)
&lt;/h2&gt;

&lt;p&gt;Think of the API Gateway as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Front door&lt;/strong&gt;: one entry point&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bouncer&lt;/strong&gt;: auth and quotas&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Traffic cop&lt;/strong&gt;: routing and balancing&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Translator&lt;/strong&gt;: protocol and payload shaping&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Receptionist&lt;/strong&gt;: aggregation and consistent error responses&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And yes, it also becomes the place everyone blames first. Enjoy.&lt;/p&gt;




&lt;h2&gt;
  
  
  Quick checklist (what you must design for)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;High availability (multi-instance, multi-zone)&lt;/li&gt;
&lt;li&gt;Observability (metrics, logs, tracing)&lt;/li&gt;
&lt;li&gt;Security controls (auth, mTLS/TLS, WAF integration if needed)&lt;/li&gt;
&lt;li&gt;Rate limits / quotas&lt;/li&gt;
&lt;li&gt;Deployment strategy (blue/green, canary for config changes)&lt;/li&gt;
&lt;li&gt;Clear ownership (someone must maintain it)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Closing thoughts
&lt;/h2&gt;

&lt;p&gt;API Gateways are not magic. They are &lt;strong&gt;concentrated responsibility&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Done well, they simplify everything. Done poorly, they become the world’s most expensive bottleneck.&lt;/p&gt;

&lt;p&gt;If you’re building microservices: you’re probably going to end up here anyway. Might as well do it on purpose.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Want a follow-up? I can write part 2 on “API Gateway vs API Management” or “Kubernetes: Ingress vs Gateway API vs Service Mesh” with real deployment patterns.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>apigateway</category>
      <category>webdev</category>
      <category>programming</category>
      <category>devops</category>
    </item>
    <item>
      <title>🦆 DuckDB: The SQLite of Analytics You Didn’t Know You Needed</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Wed, 20 Aug 2025 06:25:47 +0000</pubDate>
      <link>https://dev.to/sanukhandev/duckdb-the-sqlite-of-analytics-you-didnt-know-you-needed-579m</link>
      <guid>https://dev.to/sanukhandev/duckdb-the-sqlite-of-analytics-you-didnt-know-you-needed-579m</guid>
      <description>&lt;h2&gt;
  
  
  🦆 DuckDB: The SQLite of Analytics You Didn’t Know You Needed
&lt;/h2&gt;

&lt;h2&gt;
  
  
  🔥 Why This Matters
&lt;/h2&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%2Fef33ovh1bq9q4q4ngo8m.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%2Fef33ovh1bq9q4q4ngo8m.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every developer has faced this:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A messy CSV file too big for Excel.
&lt;/li&gt;
&lt;li&gt;A Pandas dataframe that takes forever to group by.
&lt;/li&gt;
&lt;li&gt;A dataset that’s &lt;strong&gt;too small for BigQuery but too big for comfort&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Enter &lt;strong&gt;DuckDB&lt;/strong&gt; — the &lt;em&gt;SQLite for analytics&lt;/em&gt;. It runs &lt;strong&gt;inside your app&lt;/strong&gt;, speaks &lt;strong&gt;SQL fluently&lt;/strong&gt;, and can chew through billions of rows without breaking a sweat.  &lt;/p&gt;

&lt;p&gt;And here’s the kicker: &lt;strong&gt;no server, no setup, no ops&lt;/strong&gt;.  &lt;/p&gt;




&lt;h2&gt;
  
  
  🛠 What Exactly Is DuckDB?
&lt;/h2&gt;

&lt;p&gt;DuckDB is an &lt;strong&gt;open-source, in-process OLAP database&lt;/strong&gt; designed for analytics.&lt;br&gt;&lt;br&gt;
Think of it like this:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SQLite → OLTP&lt;/strong&gt; (fast transactions, mobile apps).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DuckDB → OLAP&lt;/strong&gt; (fast analytics, big aggregations).
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Key highlights:&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Columnar storage&lt;/strong&gt; → perfect for crunching numbers.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Vectorized execution&lt;/strong&gt; → lightning-fast queries.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Embeddable&lt;/strong&gt; → runs inside your app, notebook, or script.&lt;br&gt;&lt;br&gt;
✅ &lt;strong&gt;Zero config&lt;/strong&gt; → just &lt;code&gt;pip install duckdb&lt;/code&gt; and go.  &lt;/p&gt;


&lt;h2&gt;
  
  
  ⚡ Why Developers Love It
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Faster than Pandas&lt;/strong&gt; for many data wrangling tasks.
&lt;/li&gt;
&lt;li&gt;Reads CSV, Parquet, JSON, Arrow — &lt;em&gt;directly&lt;/em&gt;.
&lt;/li&gt;
&lt;li&gt;Works seamlessly with &lt;strong&gt;Python, R, or even C++&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;Portable, lightweight, and reproducible.
&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  🚀 Real-World Use Cases
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. &lt;strong&gt;Data Science Notebooks&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Query CSVs and Parquet files with pure SQL. No database servers, no ETL.&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;duckdb&lt;/span&gt;
&lt;span class="n"&gt;duckdb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sql&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SELECT category, AVG(price) FROM &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;products.parquet&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; GROUP BY category&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;h3&gt;
  
  
  2. &lt;strong&gt;ETL Pipelines&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Replace slow Pandas joins and filters with DuckDB SQL queries.  &lt;/p&gt;




&lt;h3&gt;
  
  
  3. &lt;strong&gt;IoT &amp;amp; Edge Devices&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Run analytics on a Raspberry Pi before sending summarized data upstream.  &lt;/p&gt;




&lt;h3&gt;
  
  
  4. &lt;strong&gt;App Embedding&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Bundle DuckDB into your desktop or mobile app for &lt;strong&gt;offline analytics&lt;/strong&gt;.  &lt;/p&gt;




&lt;h3&gt;
  
  
  5. &lt;strong&gt;Rapid BI &amp;amp; ML Prototyping&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Test KPIs or prepare ML features locally before pushing to cloud warehouses.  &lt;/p&gt;




&lt;h2&gt;
  
  
  🥊 DuckDB vs The Rest
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;SQLite&lt;/strong&gt; → Great for small apps &amp;amp; transactions. Not built for analytics.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pandas/Polars&lt;/strong&gt; → In-memory only. DuckDB can handle much bigger data.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;BigQuery/Snowflake&lt;/strong&gt; → Awesome for huge data. But overkill (and $$$) for small to mid datasets.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 DuckDB fits the &lt;strong&gt;sweet spot&lt;/strong&gt;: big enough to be powerful, small enough to be simple.  &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%2Fbfp4zqpmkk6u7m30kdnr.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%2Fbfp4zqpmkk6u7m30kdnr.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✨ 10 Killer DuckDB Tricks Every Dev Should Know
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Query CSV/Parquet without loading&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="s1"&gt;'data.csv'&lt;/span&gt; &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;10&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;Query Pandas DataFrames directly&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&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;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;duckdb&lt;/span&gt;
   &lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sales.csv&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;duckdb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sql&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SELECT region, SUM(amount) FROM df GROUP BY region&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;ol&gt;
&lt;li&gt;
&lt;strong&gt;Output to Parquet&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;COPY&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="s1"&gt;'data.csv'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;TO&lt;/span&gt; &lt;span class="s1"&gt;'data_out.parquet'&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FORMAT&lt;/span&gt; &lt;span class="n"&gt;PARQUET&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;Time-series bucketing&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;time_bucket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;INTERVAL&lt;/span&gt; &lt;span class="s1"&gt;'1 hour'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;timestamp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;hour&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;AVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="s1"&gt;'iot_data.parquet'&lt;/span&gt;
   &lt;span class="k"&gt;GROUP&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;hour&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;Join multiple file formats&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="k"&gt;SELECT&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;id&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="n"&gt;details&lt;/span&gt;
   &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="s1"&gt;'customers.csv'&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
   &lt;span class="k"&gt;JOIN&lt;/span&gt; &lt;span class="s1"&gt;'orders.parquet'&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="k"&gt;ON&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;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;customer_id&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;p&gt;&lt;strong&gt;Work with Arrow/Polars seamlessly&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Direct conversion with zero copy.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Parallel execution by default&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Queries scale with your CPU cores out-of-the-box.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Run in-memory or persistent mode&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;   &lt;span class="n"&gt;PRAGMA&lt;/span&gt; &lt;span class="n"&gt;database_list&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;Export query results back to Pandas&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;   &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;duckdb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sql&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SELECT COUNT(*) FROM df&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;to_df&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;SQL + Python mix&lt;/strong&gt;
Combine data wrangling in Pandas with analytics in DuckDB.
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  ✍️ Author Insights
&lt;/h2&gt;

&lt;p&gt;Honestly, DuckDB feels like a &lt;strong&gt;cheat code for developers&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I no longer upload every CSV to BigQuery just to run a few queries.
&lt;/li&gt;
&lt;li&gt;In Jupyter, I can answer 80% of business questions without leaving my notebook.
&lt;/li&gt;
&lt;li&gt;For teaching SQL to data science juniors, DuckDB is frictionless.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s the kind of tool that makes you go: &lt;em&gt;“Where has this been all my life?”&lt;/em&gt;  &lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 Recommendations
&lt;/h2&gt;

&lt;p&gt;✅ &lt;strong&gt;Use DuckDB when&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need &lt;strong&gt;lightweight analytics&lt;/strong&gt; inside apps or notebooks.
&lt;/li&gt;
&lt;li&gt;Your datasets are &lt;strong&gt;MBs → 100s of GBs&lt;/strong&gt;, not petabytes.
&lt;/li&gt;
&lt;li&gt;You want &lt;strong&gt;reproducibility&lt;/strong&gt; without server dependencies.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;❌ &lt;strong&gt;Don’t use DuckDB when&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need &lt;strong&gt;concurrent transactions&lt;/strong&gt; (OLTP apps → use Postgres/SQLite).
&lt;/li&gt;
&lt;li&gt;You’re working with &lt;strong&gt;petabyte-scale warehouses&lt;/strong&gt; (→ BigQuery/Snowflake).
&lt;/li&gt;
&lt;li&gt;You require &lt;strong&gt;real-time streaming analytics&lt;/strong&gt; (→ ClickHouse, Druid).
&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;DuckDB isn’t just another database — it’s a &lt;strong&gt;movement toward lightweight, embeddable, analytics-first tools&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;If you work with data (and who doesn’t?), you’ll quickly see why it’s called the &lt;strong&gt;“SQLite for Analytics.”&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Next time you’re stuck between Pandas and BigQuery, remember:&lt;br&gt;&lt;br&gt;
👉 Just Duck It. 🦆  &lt;/p&gt;




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

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;DuckDB = Analytics engine that lives inside your app.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero setup, blazing fast, super portable.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Best for:&lt;/strong&gt; Data science, prototyping, IoT, offline analytics.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why viral?&lt;/strong&gt; → It makes data analysis &lt;em&gt;ridiculously simple&lt;/em&gt;.
&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>duckdb</category>
      <category>sql</category>
      <category>dataengineering</category>
      <category>datascience</category>
    </item>
    <item>
      <title>JavaScript Proxy Explained: Powerful Tips for Dynamic Object Handling</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Mon, 07 Jul 2025 12:42:29 +0000</pubDate>
      <link>https://dev.to/sanukhandev/unmasking-javascript-proxies-the-secret-agents-of-your-objects-4eac</link>
      <guid>https://dev.to/sanukhandev/unmasking-javascript-proxies-the-secret-agents-of-your-objects-4eac</guid>
      <description>&lt;p&gt;Learn how to use JavaScript's &lt;code&gt;Proxy&lt;/code&gt; object to intercept and control object behaviour. Includes real-world use cases like validation, logging, access control, and reactivity.&lt;/p&gt;

&lt;p&gt;JavaScript is full of surprises, and one of the most powerful yet underrated features is the &lt;code&gt;Proxy&lt;/code&gt; object. It allows you to intercept, customise, and secure operations on other objects without modifying them directly.&lt;/p&gt;

&lt;p&gt;Whether you're building a reactive UI, logging access, or applying security rules, &lt;code&gt;Proxy&lt;/code&gt; can be your best friend.&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%2Fs9hsy7uo9zyku0xl1k29.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%2Fs9hsy7uo9zyku0xl1k29.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 What is a JavaScript Proxy?
&lt;/h2&gt;

&lt;p&gt;In simple terms, a &lt;strong&gt;Proxy&lt;/strong&gt; wraps an object and allows you to define custom behaviour for fundamental operations like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading (&lt;code&gt;get&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Writing (&lt;code&gt;set&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Deleting (&lt;code&gt;deleteProperty&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Function invocation (&lt;code&gt;apply&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Enumeration (&lt;code&gt;ownKeys&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;And more...&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  💡 Syntax
&lt;/h3&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;proxy&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;target&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;target&lt;/strong&gt;: The object you want to proxy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;handler&lt;/strong&gt;: An object that defines "traps" (functions that override default behaviour).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💼 Real-World Use Cases for Proxy in JavaScript
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. 📊 Logging Property Access
&lt;/h3&gt;

&lt;p&gt;Want to know when properties are accessed? A Proxy lets you track this easily.&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;Adnan&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Admin&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;loggedUser&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="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;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="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;loggedUser&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.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&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%2F75rs3uf4zx552mn97nwb.png" alt=" " width="800" height="533"&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2. 🛡️ Validating Property Values
&lt;/h3&gt;

&lt;p&gt;Enforce rules when users update object properties.&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;settings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;50&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;validatedSettings&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;settings&lt;/span&gt;&lt;span class="p"&gt;,&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;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="nx"&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="nx"&gt;prop&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;volume&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&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="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;100&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Volume must be between 0 and 100&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;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="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&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="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;validatedSettings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// ✅ OK&lt;/span&gt;
&lt;span class="nx"&gt;validatedSettings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ❌ Error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fudrug2loix1gzfubw68x.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%2Fudrug2loix1gzfubw68x.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  3. 🔐 Restricting Access to Sensitive Properties
&lt;/h3&gt;

&lt;p&gt;Block access to confidential data like &lt;code&gt;salary&lt;/code&gt; or &lt;code&gt;SSN&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;employee&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;Jane&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;7000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Manager&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;secureEmployee&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;employee&lt;/span&gt;&lt;span class="p"&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;salary&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;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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Access denied to salary&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;return&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="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;secureEmployee&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;// ✅ "Jane"&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;secureEmployee&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;salary&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ❌ Error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fzfyfelf57b129uofsgep.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%2Fzfyfelf57b129uofsgep.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  4. 🔄 Auto-Fallback for Missing Properties
&lt;/h3&gt;

&lt;p&gt;No more checking if a key exists—return defaults automatically.&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;defaultConfig&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="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="p"&gt;:&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="o"&gt;=&amp;gt;&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Not set&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;defaultConfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "Not set"&lt;/span&gt;
&lt;span class="nx"&gt;defaultConfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dark&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;defaultConfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "dark"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fnrteqfg0vxuxu1uk9t5x.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%2Fnrteqfg0vxuxu1uk9t5x.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  5. 🚫 Making Objects Immutable
&lt;/h3&gt;

&lt;p&gt;Use Proxies to freeze an object’s properties dynamically.&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;constants&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;API_KEY&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;12345-SECRET&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;immutable&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;constants&lt;/span&gt;&lt;span class="p"&gt;,&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="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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cannot modify constant values!&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="nf"&gt;deleteProperty&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cannot delete properties!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;immutable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;API_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;HACKED&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ❌ Error&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2F2pgxgzwuugb3jv10c403.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%2F2pgxgzwuugb3jv10c403.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ Behind the Scenes: How Frameworks Use Proxy
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔄 Vue 3 Reactivity
&lt;/h3&gt;

&lt;p&gt;Vue.js 3 uses &lt;code&gt;Proxy&lt;/code&gt; for its &lt;strong&gt;reactivity system&lt;/strong&gt;, replacing the older &lt;code&gt;Object.defineProperty&lt;/code&gt; approach used in Vue 2.&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;reactive&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&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;state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;reactive&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Vue tracks changes via Proxy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Frmbl6fu413rwwrqzg1n2.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%2Frmbl6fu413rwwrqzg1n2.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Benefits of Using Proxy
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🐞 &lt;strong&gt;Debugging&lt;/strong&gt;: Track object usage.&lt;/li&gt;
&lt;li&gt;🧼 &lt;strong&gt;Validation&lt;/strong&gt;: Ensure correct data.&lt;/li&gt;
&lt;li&gt;🛡 &lt;strong&gt;Security&lt;/strong&gt;: Hide sensitive info.&lt;/li&gt;
&lt;li&gt;🧠 &lt;strong&gt;Customization&lt;/strong&gt;: Dynamic behavior.&lt;/li&gt;
&lt;li&gt;💡 &lt;strong&gt;Fallbacks&lt;/strong&gt;: Return default values on the fly.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚠️ Caution When Using Proxy
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Can make debugging harder if misused.&lt;/li&gt;
&lt;li&gt;Slight performance cost compared to plain objects.&lt;/li&gt;
&lt;li&gt;Doesn’t intercept internal slots of built-in types (e.g., Date).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📘 Further Reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy" rel="noopener noreferrer"&gt;MDN Web Docs: Proxy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vuejs.org/guide/essentials/reactivity-fundamentals.html" rel="noopener noreferrer"&gt;Vue 3 Reactivity System&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.bitsrc.io/javascript-proxies-complete-guide-3c26f1243a68" rel="noopener noreferrer"&gt;Advanced Proxy Patterns&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;JavaScript Proxies are like magical middlemen—they watch, intercept, and control object behaviour without messing with the original code. Whether you’re developing frameworks, building secure apps, or writing custom logging, &lt;strong&gt;Proxies give you superpowers&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Have you used &lt;code&gt;Proxy&lt;/code&gt; in production?&lt;br&gt;&lt;br&gt;
💬 Share your use cases in the comments!&lt;/p&gt;




&lt;h2&gt;
  
  
  🏷️ Tags
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;#javascript&lt;/code&gt; &lt;code&gt;#webdev&lt;/code&gt; &lt;code&gt;#frontend&lt;/code&gt; &lt;code&gt;#programming&lt;/code&gt; &lt;code&gt;#vuejs&lt;/code&gt; &lt;code&gt;#codingtips&lt;/code&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>programming</category>
    </item>
    <item>
      <title>Creating a Merge Sort Array Prototype for Nested Objects, Strings, and Numbers in JavaScript</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Wed, 18 Jun 2025 07:01:41 +0000</pubDate>
      <link>https://dev.to/sanukhandev/creating-a-merge-sort-array-prototype-for-nested-objects-strings-and-numbers-in-javascript-4l3j</link>
      <guid>https://dev.to/sanukhandev/creating-a-merge-sort-array-prototype-for-nested-objects-strings-and-numbers-in-javascript-4l3j</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Learn how to extend JavaScript's Array prototype with a powerful and flexible merge sort function that supports nested objects, strings, and numbers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  🧠 Creating a Merge Sort Array Prototype for Nested Objects, Strings, and Numbers
&lt;/h1&gt;

&lt;p&gt;Sorting arrays is easy — until you need to sort deeply nested objects, ensure stable results, or avoid mutating the original array.&lt;/p&gt;

&lt;p&gt;In this post, you’ll learn how to create a powerful, non-mutating &lt;code&gt;mergeSortBy()&lt;/code&gt; function on the &lt;code&gt;Array.prototype&lt;/code&gt; that supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Numbers&lt;/li&gt;
&lt;li&gt;✅ Strings (case-insensitive)&lt;/li&gt;
&lt;li&gt;✅ Complex nested object keys (e.g., &lt;code&gt;"user.address.city"&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;✅ Custom comparator functions&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9mzoxl2pc5edp1wgpban.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%2F9mzoxl2pc5edp1wgpban.png" alt="Image description" width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 Why Not Just Use &lt;code&gt;.sort()&lt;/code&gt;?
&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;code&gt;Array.sort()&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;mergeSortBy()&lt;/code&gt; (Custom)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Mutates original array?&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stable sort?&lt;/td&gt;
&lt;td&gt;❌ Not guaranteed before ES10&lt;/td&gt;
&lt;td&gt;✅ Always&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deep key sorting?&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supports custom comparator?&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🔄 Step 1: Get Nested Values
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function getValue(obj, path) {
  return path.split('.').reduce((acc, key) =&amp;gt; acc?.[key], obj);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧮 Step 2: Comparator Helper
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function defaultComparator(a, b) {
  if (a == null &amp;amp;&amp;amp; b != null) return -1;
  if (a != null &amp;amp;&amp;amp; b == null) return 1;
  if (typeof a === 'string' &amp;amp;&amp;amp; typeof b === 'string') {
    return a.localeCompare(b);
  }
  return a &amp;gt; b ? 1 : a &amp;lt; b ? -1 : 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧩 Step 3: &lt;code&gt;mergeSortBy&lt;/code&gt; on Array.prototype
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (!Array.prototype.mergeSortBy) {
  Array.prototype.mergeSortBy = function (keyOrFn) {
    const getComparator = () =&amp;gt; {
      if (typeof keyOrFn === 'function') return keyOrFn;
      if (typeof keyOrFn === 'string') {
        return (a, b) =&amp;gt;
          defaultComparator(getValue(a, keyOrFn), getValue(b, keyOrFn));
      }
      return defaultComparator;
    };

    const merge = (left, right, comparator) =&amp;gt; {
      const result = [];
      let i = 0, j = 0;
      while (i &amp;lt; left.length &amp;amp;&amp;amp; j &amp;lt; right.length) {
        result.push(
          comparator(left[i], right[j]) &amp;lt;= 0 ? left[i++] : right[j++]
        );
      }
      return result.concat(left.slice(i), right.slice(j));
    };

    const mergeSort = (arr, comparator) =&amp;gt; {
      if (arr.length &amp;lt;= 1) return arr;
      const mid = Math.floor(arr.length / 2);
      const left = mergeSort(arr.slice(0, mid), comparator);
      const right = mergeSort(arr.slice(mid), comparator);
      return merge(left, right, comparator);
    };

    return mergeSort(this.slice(), getComparator()); // non-mutating
  };
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧪 Test Cases &amp;amp; Real Examples
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ✅ 1. Sort numbers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[9, 1, 4, 7].mergeSortBy(); // [1, 4, 7, 9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  ✅ 2. Sort strings
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;["banana", "Apple", "cherry"].mergeSortBy();
// Output: ['Apple', 'banana', 'cherry']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  ✅ 3. Sort objects with deep keys
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const users = [
  { id: 1, profile: { name: "John" } },
  { id: 2, profile: { name: "Alice" } },
  { id: 3, profile: { name: "Bob" } },
];

const sortedUsers = users.mergeSortBy("profile.name");
console.log(sortedUsers.map(u =&amp;gt; u.profile.name)); 
// ['Alice', 'Bob', 'John']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  ✅ 4. Custom comparator
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const scores = [
  { name: "A", score: 90 },
  { name: "B", score: 100 },
  { name: "C", score: 95 },
];

const desc = scores.mergeSortBy((a, b) =&amp;gt; b.score - a.score);
console.log(desc.map(x =&amp;gt; x.score)); // [100, 95, 90]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  ⏱ Performance Comparison: &lt;code&gt;.sort()&lt;/code&gt; vs &lt;code&gt;mergeSortBy()&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const bigArray = Array.from({ length: 100000 }, () =&amp;gt; ({
  id: Math.random().toString(36).substring(7),
  value: Math.floor(Math.random() * 100)
}));

console.time("Native sort");
bigArray.slice().sort((a, b) =&amp;gt; a.value - b.value);
console.timeEnd("Native sort");

console.time("mergeSortBy");
bigArray.mergeSortBy("value");
console.timeEnd("mergeSortBy");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  ✅ Stability Test
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const people = [
  { name: "Alice", age: 30 },
  { name: "Bob", age: 25 },
  { name: "Charlie", age: 30 },
];

const sorted = people.mergeSortBy("age");
console.log(sorted.map(p =&amp;gt; p.name)); 
// ['Bob', 'Alice', 'Charlie'] — Alice before Charlie (same age) ⇒ stable!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🎯 Final Takeaways
&lt;/h2&gt;

&lt;p&gt;You just built a custom merge sort that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Handles primitives and nested objects&lt;/li&gt;
&lt;li&gt;Accepts string paths or comparator functions&lt;/li&gt;
&lt;li&gt;Is stable and predictable&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ⚠️ Performance: Why Native &lt;code&gt;.sort()&lt;/code&gt; Is Faster Than &lt;code&gt;mergeSort()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;After testing both &lt;code&gt;Array.prototype.sort()&lt;/code&gt; and our custom &lt;code&gt;mergeSort()&lt;/code&gt; on complex nested data, the results are clear:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Native Sort: ✅ Faster (~1.3ms)  
Merge Sort: ❌ Slower (~8.5ms)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🚀 Why is Native &lt;code&gt;.sort()&lt;/code&gt; Faster?
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Reason&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Engine Optimized&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Native &lt;code&gt;.sort()&lt;/code&gt; is implemented in low-level languages like C++ inside JS engines (e.g., V8).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Hybrid Sorting&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Modern engines use &lt;strong&gt;Timsort&lt;/strong&gt; — a hybrid of Merge and Insertion sort — optimized for real-world data.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Better Memory Handling&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Avoids frequent array cloning operations like &lt;code&gt;slice()&lt;/code&gt; and &lt;code&gt;shift()&lt;/code&gt;, which are costly in JavaScript.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;In-place Sorting&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Operates directly on the original array without creating new intermediate arrays.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Small-Array Optimization&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;For short arrays, engines switch to &lt;strong&gt;insertion sort&lt;/strong&gt;, which is extremely fast.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  📚 Then Why Bother With &lt;code&gt;mergeSort()&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;While native sort is faster, writing your own &lt;code&gt;mergeSort()&lt;/code&gt; still has value:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Educational&lt;/strong&gt;: Great way to learn recursion and sorting logic.&lt;/li&gt;
&lt;li&gt;🔍 &lt;strong&gt;Transparent&lt;/strong&gt;: Full control over how elements are compared and sorted.&lt;/li&gt;
&lt;li&gt;🔄 &lt;strong&gt;Immutable Structures&lt;/strong&gt;: Useful in environments where mutation is discouraged.&lt;/li&gt;
&lt;li&gt;📊 &lt;strong&gt;Benchmarking&lt;/strong&gt;: Compare against other algorithms (QuickSort, HeapSort, etc.) for algorithm study.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🧠 Takeaway
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Use &lt;code&gt;.sort()&lt;/code&gt; in production.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Use &lt;code&gt;mergeSort()&lt;/code&gt; to understand how sorting works under the hood.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;







&lt;h2&gt;
  
  
  📬 What Next?
&lt;/h2&gt;

&lt;p&gt;Let me know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Would you like a TypeScript version?&lt;/li&gt;
&lt;li&gt;Should this be a standalone NPM utility?&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;⭐ Found this helpful? Drop a like, comment, or bookmark!&lt;/p&gt;
&lt;/blockquote&gt;




</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Struggling with LeetCode brute force? 💻 Try Project Euler — a powerful DSA trainer that sharpens logic, math, and optimisation skills. I’ve broken https://dev.to/sanukhandev/why-project-euler-might-be-the-most-powerful-dsa-trainer-youre-not-using-yet-293c</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Wed, 18 Jun 2025 06:36:26 +0000</pubDate>
      <link>https://dev.to/sanukhandev/struggling-with-leetcode-brute-force-try-project-euler-a-powerful-dsa-trainer-that-sharpens-4hii</link>
      <guid>https://dev.to/sanukhandev/struggling-with-leetcode-brute-force-try-project-euler-a-powerful-dsa-trainer-that-sharpens-4hii</guid>
      <description></description>
      <category>leetcode</category>
      <category>dsa</category>
      <category>algorithms</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Why Project Euler Might Be the Most Powerful DSA Trainer You're Not Using Yet</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Tue, 17 Jun 2025 07:41:04 +0000</pubDate>
      <link>https://dev.to/sanukhandev/why-project-euler-might-be-the-most-powerful-dsa-trainer-youre-not-using-yet-293c</link>
      <guid>https://dev.to/sanukhandev/why-project-euler-might-be-the-most-powerful-dsa-trainer-youre-not-using-yet-293c</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“Most coders know LeetCode. Fewer know Project Euler. But those who do? They think deeper, optimise faster, and solve smarter.”&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&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%2Fjq4gksba2sqzeggjgvi5.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%2Fjq4gksba2sqzeggjgvi5.png" alt="Banner Image Euler's Equation" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📚 A Tale of Two Coders
&lt;/h2&gt;

&lt;p&gt;Imagine two coders:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Alex&lt;/strong&gt; solves classic interview-style problems on LeetCode.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Riya&lt;/strong&gt; prefers tackling math-based programming puzzles on &lt;strong&gt;Project Euler&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A few months in, Riya is noticeably better at optimisation, pattern spotting, and problem-solving.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What changed?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
👉 &lt;em&gt;She trained with Project Euler.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 What &lt;em&gt;Exactly&lt;/em&gt; Is Project Euler?
&lt;/h2&gt;

&lt;p&gt;Project Euler is a collection of 800+ curated problems that blend math, logic, and programming.&lt;/p&gt;

&lt;p&gt;Each problem challenges you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spot patterns 🧩
&lt;/li&gt;
&lt;li&gt;Think algorithmically 🧠
&lt;/li&gt;
&lt;li&gt;Solve problems &lt;strong&gt;without hand-holding&lt;/strong&gt; 🎯
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Unlike most platforms, it doesn’t give you test cases — it gives you a &lt;strong&gt;riddle&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🪜 Your 4-Phase Project Euler + DSA Roadmap
&lt;/h2&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%2Fmzcb9zxtsdkra8ez71rx.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%2Fmzcb9zxtsdkra8ez71rx.png" alt="A video game level progression map with 4 stages labeled: Beginner, Intermediate, Advanced, Expert — each with code-related icons and glowing challenge gates — flat vector style" width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  🌱 Phase 1: Build Your Foundation (Problems 1–10)
&lt;/h3&gt;

&lt;p&gt;Start with core programming concepts: loops, conditions, and math patterns.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 Example:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Problem 1 – Sum of Multiples of 3 and 5&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
How many numbers below 1000 are divisible by 3 or 5?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;✅ Skills: loops, modulus, arithmetic optimisation&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  🌿 Phase 2: Master Core DSA (Problems 11–40)
&lt;/h3&gt;

&lt;p&gt;Here, problems require &lt;strong&gt;recursion&lt;/strong&gt;, &lt;strong&gt;memoization&lt;/strong&gt;, and &lt;strong&gt;array logic&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 Example:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Problem 14 – Longest Collatz Sequence&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Which number under 1 million produces the longest sequence?&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;✅ Skills: HashMaps, recursion, memoisation&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  🌳 Phase 3: Think Algorithmically (Problems 41–80)
&lt;/h3&gt;

&lt;p&gt;Time to introduce &lt;strong&gt;sieves&lt;/strong&gt;, &lt;strong&gt;prefix sums&lt;/strong&gt;, and &lt;strong&gt;backtracking&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 Example:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Problem 50 – Consecutive Prime Sum&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Find the prime below 1 million that can be written as the longest sum of consecutive primes.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;✅ Skills: Modular math, optimisation, big number handling&lt;/p&gt;
&lt;/blockquote&gt;




&lt;blockquote&gt;
&lt;p&gt;✅ Skills: Prime sieve, sliding window, prefix sum&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  🌲 Phase 4: Engineer Like a Mathematician (81+)
&lt;/h3&gt;

&lt;p&gt;This level is serious: matrix DP, modular exponentiation, and combinatorics.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 Example:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Problem 97 – Large Non-Mersenne Prime&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
What are the last 10 digits of a massive prime number expression?&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%2F0044gajyhepde7tmpis9.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%2F0044gajyhepde7tmpis9.png" alt="Abstract brain made of code and math equations, connected to a computer chip — futuristic glowing design in dark mode" width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  💻 Which Language Should You Use?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Language&lt;/th&gt;
&lt;th&gt;Why It’s Good&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;-------------------------------------------------------------|&lt;br&gt;
| &lt;strong&gt;Python&lt;/strong&gt; | Easy syntax, built-in big integers, math libs |&lt;br&gt;
| C++        | Performance-heavy problems, manual control    |&lt;br&gt;
| Java       | Strong typing, BigInteger support             |&lt;br&gt;
| Haskell    | Elegant solutions, great for math-heavy logic |&lt;/p&gt;

&lt;p&gt;🏆 &lt;strong&gt;Best Choice:&lt;/strong&gt; Python — it’s perfect for Euler’s math + logic challenges.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔥 Why Most People Ignore Project Euler (And Why You Shouldn’t)
&lt;/h2&gt;

&lt;p&gt;Common reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Too mathematical.”&lt;/li&gt;
&lt;li&gt;“Not practical for interviews.”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💡 Truth: Project Euler &lt;strong&gt;teaches you optimization, reasoning, and how to build your own test cases&lt;/strong&gt; — skills that ace interviews and improve real-world coding.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Euler makes you &lt;strong&gt;solve smarter&lt;/strong&gt;, not just faster.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🎯 Getting Started (Today!)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://projecteuler.net/" rel="noopener noreferrer"&gt;projecteuler.net&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Create an account.&lt;/li&gt;
&lt;li&gt;Start with Problem 1.&lt;/li&gt;
&lt;li&gt;Write your code, refactor, and &lt;strong&gt;reflect&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;What DSA did you use?&lt;/li&gt;
&lt;li&gt;How did you optimize?&lt;/li&gt;
&lt;li&gt;What patterns did you discover?&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;✅ Bonus: Post your solutions weekly on GitHub or LinkedIn for habit + portfolio building.&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%2Frx1gyyp79p54scu5k8bf.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%2Frx1gyyp79p54scu5k8bf.png" alt="A focused developer surrounded by mathematical symbols, writing code on a glowing laptop in a dimly lit workspace — high contrast digital painting style." width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;




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

&lt;p&gt;If you want to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Crack interviews&lt;/li&gt;
&lt;li&gt;Think like an algorithm designer&lt;/li&gt;
&lt;li&gt;Train for the ICPC/Codeforces level&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;… then &lt;strong&gt;Project Euler is your secret weapon.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Start with 1 problem per day. Let the puzzle teach you.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  💬 Let's Talk
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;What’s the first Euler problem you’ll try?&lt;/li&gt;
&lt;li&gt;Want a public leaderboard challenge every weekend?&lt;/li&gt;
&lt;li&gt;Interested in a curated “Euler Weekly” newsletter?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Comment below or DM to join a challenge group. Let’s think deeper, together.&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>python</category>
      <category>projecteuler</category>
      <category>programming</category>
    </item>
    <item>
      <title>How Warp Terminal Saved Me from a Git Disaster (With Just One Prompt)</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Thu, 08 May 2025 08:50:06 +0000</pubDate>
      <link>https://dev.to/sanukhandev/how-warp-terminal-saved-me-from-a-git-disaster-with-just-one-prompt-3fge</link>
      <guid>https://dev.to/sanukhandev/how-warp-terminal-saved-me-from-a-git-disaster-with-just-one-prompt-3fge</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;When Git rebasing goes wrong, Warp Terminal can be your smartest ally. Here's how it helped me reset my branch in seconds.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you've ever found yourself tangled in a Git mess—conflicts mid-rebase, local changes everywhere, and that sinking feeling of “I’ve broken everything”—you’re not alone. That was me, staring at my screen, mid-panic, until &lt;strong&gt;Warp Terminal&lt;/strong&gt; stepped in like a superhero with a command cape.&lt;/p&gt;

&lt;p&gt;I was knee-deep in a rebase gone wrong. My local branch &lt;code&gt;dev/1.0.0-2025&lt;/code&gt; was full of merge conflicts, and the more I tried to fix it, the messier it got. I just wanted to &lt;strong&gt;reset everything to match the remote branch&lt;/strong&gt;. A clean slate.&lt;/p&gt;

&lt;p&gt;Normally, this means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Checking status&lt;/li&gt;
&lt;li&gt;Aborting rebase&lt;/li&gt;
&lt;li&gt;Fetching from origin&lt;/li&gt;
&lt;li&gt;Hard resetting&lt;/li&gt;
&lt;li&gt;Cleaning up&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;…and crossing your fingers that nothing breaks.&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚡ Enter: Warp Terminal
&lt;/h2&gt;

&lt;p&gt;Before I show how Warp rescued me, let me introduce it briefly.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://www.warp.dev" rel="noopener noreferrer"&gt;&lt;strong&gt;Warp&lt;/strong&gt;&lt;/a&gt; is a modern terminal built in Rust, designed for the way developers work &lt;strong&gt;today&lt;/strong&gt;. Some standout features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blazing fast performance&lt;/li&gt;
&lt;li&gt;Blocks-based UI (great for copy/paste and command context)&lt;/li&gt;
&lt;li&gt;Autocomplete with inline docs&lt;/li&gt;
&lt;li&gt;AI Command Search for natural-language help&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s like pairing with a senior dev who lives in your terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 Solving Git with One Prompt
&lt;/h2&gt;

&lt;p&gt;Back to the mess I was in.&lt;/p&gt;

&lt;p&gt;Instead of fumbling through Git commands, I typed this prompt in Warp:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reset to current remote
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And what I got was &lt;strong&gt;exactly what I needed&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Ensure that there are no important local changes that need to be preserved.
2. Abort the ongoing rebase operation:
   • git rebase --abort
3. Switch to the branch:
   • git checkout dev/1.0.0-2025
4. Fetch all changes:
   • git fetch --all
5. Hard-reset the branch:
   • git reset --hard origin/dev/1.0.0-2025
6. Clean untracked files:
   • git clean -fd
7. Verify everything is synced.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Warp gave me &lt;em&gt;context-aware&lt;/em&gt;, clear, and safe steps—tailored to my repo.&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%2F99ayhpzwy8up2r79emu5.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%2F99ayhpzwy8up2r79emu5.png" alt="Wrap terminal AI powered terminal" width="800" height="1180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🎯 Why It Mattered
&lt;/h2&gt;

&lt;p&gt;In less than a minute, I went from rebase chaos to a clean, synced branch—all without ever leaving my terminal. No copy-pasting from Stack Overflow. No second-guessing syntax. Just one intelligent prompt.&lt;/p&gt;

&lt;h2&gt;
  
  
  ✅ Final Thoughts: Terminal, Reinvented
&lt;/h2&gt;

&lt;p&gt;If you're still using the default terminal your OS shipped with, it's time to level up. &lt;strong&gt;Warp Terminal&lt;/strong&gt; isn’t just for looks—it’s a productivity engine.&lt;/p&gt;

&lt;p&gt;It helped me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Avoid disaster&lt;/li&gt;
&lt;li&gt;Save time&lt;/li&gt;
&lt;li&gt;Fix my branch painlessly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next time Git throws you a curveball, let Warp take the wheel.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🔗 &lt;a href="https://www.warp.dev" rel="noopener noreferrer"&gt;Try Warp for free →&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;✍️ &lt;em&gt;Have you tried Warp? Share your experience in the comments!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>terminal</category>
      <category>productivity</category>
      <category>devtools</category>
    </item>
    <item>
      <title>Building a Cost-Effective Full-Stack SaaS Platform: A Practical Guide for Small to Mid-Size IT Startups</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Tue, 22 Apr 2025 09:00:21 +0000</pubDate>
      <link>https://dev.to/sanukhandev/building-a-cost-effective-full-stack-saas-platform-a-practical-guide-for-small-to-mid-size-it-2d44</link>
      <guid>https://dev.to/sanukhandev/building-a-cost-effective-full-stack-saas-platform-a-practical-guide-for-small-to-mid-size-it-2d44</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;"It’s not the tools you have faith in – tools are just tools – they work, or they don’t. It’s the people you have faith in or not."&lt;br&gt;
— &lt;em&gt;&lt;strong&gt;Steve Jobs&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In today’s fast-evolving digital economy, building a SaaS platform isn’t just about writing code—it’s about making smart architectural choices that maximise efficiency, scalability, and cost-effectiveness. Whether you're an early-stage startup or a growing mid-sized business, setting up your SaaS infrastructure right from the start can save you thousands down the road.&lt;/p&gt;

&lt;p&gt;In this blog post, I’ll walk you through a pragmatic full-stack architecture for launching a multi-tenant SaaS platform using a blend of modern and battle-tested technologies. The key objective? Strike the perfect balance between performance, maintainability, and cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 The Tech Stack At a Glance
&lt;/h2&gt;

&lt;p&gt;This stack has been carefully chosen to balance developer productivity, cost-effectiveness, and scalability. Let’s dive deeper into the choices:&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%2Flkgwlx37pfc1dq9g3z27.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%2Flkgwlx37pfc1dq9g3z27.png" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔧 Backend API: Laravel (PHP)&lt;/strong&gt;&lt;br&gt;
Laravel offers a powerful toolkit for API development and is well-suited for structured business logic. It’s a mature framework with a massive ecosystem.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Built-in support for routing, middleware, validation, and authentication&lt;/li&gt;
&lt;li&gt;Excellent ecosystem (queues, scheduling, notifications, testing)&lt;/li&gt;
&lt;li&gt;Laravel Sanctum or Passport for secure API authentication&lt;/li&gt;
&lt;li&gt;Native support for multi-tenancy using community packages like tenancy/tenancy&lt;/li&gt;
&lt;li&gt;Easily deployable on shared hosting environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🖼 Frontend: Next.js with Tailwind CSS&lt;/strong&gt;&lt;br&gt;
Next.js provides a powerful framework for server-rendered React applications and supports hybrid static &amp;amp; SSR pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Next.js?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Built-in SSR (Server Side Rendering) for SEO and initial page performance&lt;/li&gt;
&lt;li&gt;API Routes for quick backend logic&lt;/li&gt;
&lt;li&gt;Easy routing system and middleware support&lt;/li&gt;
&lt;li&gt;Great support for subdomain routing and multitenancy frontends&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Tailwind CSS?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Utility-first approach = consistent and fast styling&lt;/li&gt;
&lt;li&gt;No need for complex CSS setups or naming conventions&lt;/li&gt;
&lt;li&gt;Responsive, mobile-first design out-of-the-box&lt;/li&gt;
&lt;li&gt;Perfect for prototyping and scaling UI design&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🗃 Database: MySQL with Multi-Tenant Strategy&lt;/strong&gt;&lt;br&gt;
MySQL remains a solid, affordable, and easy-to-manage database engine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-Tenancy Strategy:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Shared schema: All tenants share the same tables, with a tenant_id column for data separation&lt;/li&gt;
&lt;li&gt;Efficient indexing and performance for up to hundreds of tenants&lt;/li&gt;
&lt;li&gt;Easily migrate to schema-based isolation when scaling further&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Why MySQL?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Supported by all major hosting providers, including cPanel&lt;/li&gt;
&lt;li&gt;Easy backup and replication support&lt;/li&gt;
&lt;li&gt;Low overhead and proven stability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;📚 CMS: Headless WordPress&lt;/strong&gt;&lt;br&gt;
WordPress is the world's most popular CMS. Running it in headless mode delivers structured content with full control over the front end.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How it's used:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manage landing pages, blogs, FAQs, help center&lt;/li&gt;
&lt;li&gt;Integrate via REST API or GraphQL (using plugins like WPGraphQL)&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Roles and workflows for content team collaboration&lt;br&gt;
&lt;strong&gt;Why Headless WordPress?&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Familiar with content teams&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flexible and extendable with plugins&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easily managed via traditional cPanel hosting&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;📦 Master Data Management: UnoPIM with AI Integration&lt;/strong&gt;&lt;br&gt;
UnoPIM is a lightweight, modern product information management system. It's a great choice for SaaS platforms dealing with large, structured datasets like inventory, product catalogues, or standardised datasets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why UnoPIM?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SaaS-ready, low configuration PIM&lt;/li&gt;
&lt;li&gt;Supports multi-language, multi-region, multi-brand datasets&lt;/li&gt;
&lt;li&gt;Offers API-first architecture&lt;/li&gt;
&lt;li&gt;AI integration allows:&lt;/li&gt;
&lt;li&gt;Auto-tagging&lt;/li&gt;
&lt;li&gt;Product image matching&lt;/li&gt;
&lt;li&gt;Content enrichment&lt;/li&gt;
&lt;li&gt;Smart data validation and suggestions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🤝 CRM: Zoho CRM&lt;br&gt;
An affordable and scalable customer relationship management tool, Zoho CRM allows for deep integration with business logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Zoho CRM?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Excellent value at startup cost&lt;/li&gt;
&lt;li&gt;APIs for leads, deals, tasks, and custom modules&lt;/li&gt;
&lt;li&gt;Workflow automation and AI insights (Zia AI)&lt;/li&gt;
&lt;li&gt;Can be integrated with Laravel and frontend to sync users, deals, and actions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🚀 Deployment: Shared cPanel Hosting&lt;/strong&gt;&lt;br&gt;
Yes, you read that right. You don’t need AWS or DigitalOcean to get started.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Shared cPanel?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Budget-friendly ($3 to $10/month)&lt;/li&gt;
&lt;li&gt;Simple deployment of Laravel via public_html/api&lt;/li&gt;
&lt;li&gt;MySQL, Cron Jobs, SSL, FTP, Email included&lt;/li&gt;
&lt;li&gt;Easy to run Headless WordPress alongside Laravel&lt;/li&gt;
&lt;li&gt;Next.js can be deployed via npm run build &amp;amp;&amp;amp; export and served via static hosting or proxies&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;You can always migrate later to VPS, containerized (Docker) infrastructure, or use PaaS options like Heroku or Render when you're ready to scale.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;🏗️ Multi-Tenant Architecture with MySQL&lt;/strong&gt;&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%2Fup74jyl98ymo4y3nhsko.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%2Fup74jyl98ymo4y3nhsko.png" alt="Image description" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Multi-tenancy is the heart of any SaaS. In this approach, we use a shared database with tenant-level isolation using tenant IDs or schema separation. This helps us:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Minimize infrastructure costs (especially in the early stage)&lt;/li&gt;
&lt;li&gt;Easily onboard new clients with subdomain-specific logins (e.g., clientA.platform.com)&lt;/li&gt;
&lt;li&gt;Scale horizontally by abstracting tenant-specific data access&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;✅ Why MySQL?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It’s reliable, easy to maintain, and available on almost every hosting platform—perfect for lean SaaS startups not ready to pay for heavy cloud-managed DB services yet.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🌐 Subdomain Strategy: Branding + Security&lt;/strong&gt;&lt;br&gt;
Each organization gets a unique subdomain (org1.yoursaas.com, org2.yoursaas.com) that maps to their tenant space. Benefits include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better brand identity per client&lt;/li&gt;
&lt;li&gt;Seamless SSO and domain-based isolation&lt;/li&gt;
&lt;li&gt;Tenant-wise login, dashboard routing, and role-based permissions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🧱 Laravel as Backend API Layer&lt;/strong&gt;&lt;br&gt;
Laravel offers a powerful, opinionated framework for API development. Here's why it edges out Node.js in our case:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ Why Laravel over Node.js?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Built-in multi-tenancy packages like Tenancy for Laravel&lt;/li&gt;
&lt;li&gt;Rich ecosystem for auth, queues, emails, and scheduling&lt;/li&gt;
&lt;li&gt;Elegant syntax and faster MVP development&lt;/li&gt;
&lt;li&gt;Simpler to deploy on shared hosting environments like cPanel&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;⚡ Next.js (SSR) + Tailwind CSS for Frontend&lt;/strong&gt;&lt;br&gt;
The frontend stack uses Next.js for Server-Side Rendering (SSR), paired with Tailwind CSS for rapid styling.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Benefits:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better SEO and first load performance&lt;/li&gt;
&lt;li&gt;Dynamic routing for subdomains and tenant-based UI&lt;/li&gt;
&lt;li&gt;Tailwind ensures maintainable and scalable UI development with a utility-first approach&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🚀 Deployment on Shared cPanel Hosting&lt;/strong&gt;&lt;br&gt;
Yes, even in 2025, shared hosting can still be viable, especially for startups with a tight budget.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here’s how we make it work:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Laravel backend + MySQL on cPanel (using public_html/api)&lt;/li&gt;
&lt;li&gt;WordPress headless install (same or different folder)&lt;/li&gt;
&lt;li&gt;Next.js app built and exported to static files (npm run export) and served via Apache or Nginx&lt;/li&gt;
&lt;li&gt;Crons/schedulers can run via cron jobs in cPanel&lt;/li&gt;
&lt;li&gt;SSL via Autossl / Let’s Encrypt&lt;/li&gt;
&lt;li&gt;Email support and file storage at no extra cost&lt;/li&gt;
&lt;li&gt;✅ Why this makes sense for early-stage SaaS:&lt;/li&gt;
&lt;li&gt;No DevOps overhead&lt;/li&gt;
&lt;li&gt;Cheap ($3–$5/month)&lt;/li&gt;
&lt;li&gt;Built-in tools for backups, DNS, FTP, and email&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;When you scale? Just lift-and-shift to VPS, DigitalOcean, or AWS.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You don’t need a million-dollar budget to launch a world-class SaaS product. With the right choices, even small teams can build scalable, secure, and maintainable systems. The above stack empowers your team to focus on what matters most: delivering value to customers.&lt;/p&gt;

&lt;p&gt;If you're planning to launch or scale a SaaS product and want an architecture tailored to your stage, reach out or drop your questions below.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>startup</category>
      <category>agile</category>
      <category>fullstack</category>
    </item>
    <item>
      <title>Unravelling P vs NP: How This Unsolved Problem Influences the Future of AI with Quantum Computing</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Thu, 20 Jun 2024 05:49:27 +0000</pubDate>
      <link>https://dev.to/sanukhandev/unravelling-p-vs-np-how-this-unsolved-problem-influences-the-future-of-ai-with-quantum-computing-37c3</link>
      <guid>https://dev.to/sanukhandev/unravelling-p-vs-np-how-this-unsolved-problem-influences-the-future-of-ai-with-quantum-computing-37c3</guid>
      <description>&lt;p&gt;In the world of artificial intelligence, the P vs NP problem looms large as one of the most profound and challenging puzzles. This fundamental question in computer science and mathematics could be the key to unlocking the next level of AI capabilities. Understanding and solving the P vs NP problem could transform AI, making it faster, smarter, and more powerful than ever before. Moreover, the advent of quantum computing introduces a new dimension to this problem, offering potential pathways to solutions that could revolutionize AI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding P vs NP
&lt;/h2&gt;

&lt;h3&gt;
  
  
  P (Polynomial Time)
&lt;/h3&gt;

&lt;p&gt;Problems classified under P can be solved quickly by a computer. The "quickly" here means that the time taken to solve these problems scales reasonably (polynomially) with the size of the input. Examples of P problems in AI include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pathfinding algorithms for navigation.&lt;/li&gt;
&lt;li&gt;Sorting and searching large datasets.&lt;/li&gt;
&lt;li&gt;Real-time decision-making in robotics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  NP (Nondeterministic Polynomial Time)
&lt;/h3&gt;

&lt;p&gt;NP problems are those for which a solution, once found, can be verified quickly, even if finding that solution might be prohibitively time-consuming. In the context of AI, NP problems include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Optimization tasks in machine learning.&lt;/li&gt;
&lt;li&gt;Complex pattern recognition.&lt;/li&gt;
&lt;li&gt;Certain types of scheduling and resource allocation problems.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The big question: &lt;strong&gt;If a problem's solution can be verified quickly (NP), can it also be solved quickly (P)?&lt;/strong&gt; This is the essence of the P vs NP problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implications for AI
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Enhancing Machine Learning
&lt;/h3&gt;

&lt;p&gt;Machine learning, a cornerstone of modern AI, involves training algorithms on large datasets to recognize patterns and make decisions. Many machine learning tasks are essentially NP problems, where finding the optimal model parameters is computationally intensive. If P = NP, it would mean that we could find these optimal solutions quickly, dramatically improving the efficiency and effectiveness of AI systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advanced Problem Solving
&lt;/h3&gt;

&lt;p&gt;AI excels at solving problems within well-defined boundaries. However, many real-world problems are NP-hard, meaning they are currently infeasible to solve exactly within a reasonable time frame. Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Drug discovery:&lt;/strong&gt; Finding the best molecular compounds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logistics:&lt;/strong&gt; Optimizing delivery routes and supply chains.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Natural language processing:&lt;/strong&gt; Understanding and generating human language at a deep, nuanced level.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If P = NP, AI could solve these complex problems rapidly, leading to breakthroughs across various domains.&lt;/p&gt;

&lt;h3&gt;
  
  
  Revolutionizing Algorithms
&lt;/h3&gt;

&lt;p&gt;The algorithms that underpin AI systems would undergo a revolution. Currently, many AI algorithms rely on heuristics or approximations to tackle NP problems. Proving P = NP would mean that exact solutions could be found efficiently, eliminating the need for approximations and significantly increasing accuracy and reliability.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Impact on AI Research and Development
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Computational Complexity and AI
&lt;/h3&gt;

&lt;p&gt;Computational complexity, the study of resources needed to solve problems, is at the heart of AI research. Understanding the complexity of problems helps researchers develop more efficient algorithms. The P vs NP problem is a central question in this field. Its resolution would redefine what is computationally feasible, pushing the boundaries of AI research.&lt;/p&gt;

&lt;h3&gt;
  
  
  Circuit Complexity and AI
&lt;/h3&gt;

&lt;p&gt;Circuit complexity, which studies the minimum resources required to solve Boolean functions, intersects with AI in hardware design and optimization. AI systems rely on hardware to perform computations efficiently. Solving P vs NP could lead to new, more efficient hardware designs, further boosting AI performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Meta-Complexity in AI
&lt;/h3&gt;

&lt;p&gt;Meta-complexity explores the difficulty of determining the hardness of computational problems. This has implications for AI in terms of understanding the limits of what AI can achieve. Solving P vs NP would provide new insights into the theoretical capabilities of AI, guiding future research directions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quantum Computing and P vs NP
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Quantum Computing: A New Paradigm
&lt;/h3&gt;

&lt;p&gt;Quantum computing leverages the principles of quantum mechanics to process information in fundamentally different ways than classical computers. Quantum bits (qubits) can represent both 0 and 1 simultaneously, enabling the parallel processing of vast amounts of data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hypothetical Solutions with Quantum Computing
&lt;/h3&gt;

&lt;p&gt;Quantum computing holds the potential to revolutionize the P vs NP problem by providing new approaches to problem-solving:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quantum Algorithms:&lt;/strong&gt; Algorithms like Shor’s algorithm and Grover’s algorithm demonstrate that quantum computers can solve specific problems much faster than classical computers. If similar quantum algorithms are developed for NP problems, it could lead to breakthroughs in AI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parallel Processing Power:&lt;/strong&gt; Quantum computers can explore multiple solutions simultaneously, potentially finding solutions to NP problems more efficiently. This parallelism could drastically reduce the time required to solve complex AI problems.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quantum Annealing:&lt;/strong&gt; Techniques like quantum annealing are already being used to tackle optimization problems, which are central to AI. These methods could be extended to address NP problems, providing faster and more accurate solutions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Future of AI with Quantum Computing
&lt;/h3&gt;

&lt;p&gt;If quantum computing can provide a pathway to solving the P vs NP problem, the implications for AI are profound:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Unprecedented Computational Power:&lt;/strong&gt; AI systems would gain access to unprecedented computational power, enabling them to solve previously intractable problems quickly and accurately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced Machine Learning:&lt;/strong&gt; Quantum machine learning algorithms could learn from data more efficiently, leading to faster and more powerful AI models.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Breakthroughs in Various Fields:&lt;/strong&gt; Fields like cryptography, drug discovery, and logistics would experience transformative advancements, driven by AI’s enhanced problem-solving capabilities.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Security Considerations
&lt;/h2&gt;

&lt;p&gt;The potential power of AI in a world where P = NP or quantum computing solves NP problems comes with ethical and security challenges. The ability to solve complex problems quickly could be used for malicious purposes, such as cracking encryption codes. It is crucial to develop ethical guidelines and robust security measures to ensure that AI advancements are used for the benefit of society.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Thoughts
&lt;/h2&gt;

&lt;p&gt;The P vs NP problem is more than an abstract mathematical question; it is a key to unlocking AI’s full potential. Solving this problem, especially with the aid of quantum computing, could lead to AI systems that are vastly more powerful and capable, revolutionizing industries and solving some of humanity’s most challenging problems. As researchers continue to explore this enigma, the future of AI looks both exciting and transformative. The journey to solve P vs NP promises to be one of the most impactful quests in the history of science and technology, with AI standing to gain immensely from its resolution.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>computerscience</category>
      <category>computing</category>
      <category>programming</category>
    </item>
    <item>
      <title>P vs NP Problem: The Ultimate Computer / Math Puzzle</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Wed, 19 Jun 2024 09:26:34 +0000</pubDate>
      <link>https://dev.to/sanukhandev/p-vs-np-problem-the-ultimate-computer-math-puzzle-5hj0</link>
      <guid>https://dev.to/sanukhandev/p-vs-np-problem-the-ultimate-computer-math-puzzle-5hj0</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/challenges/cs"&gt;DEV Computer Science Challenge v24.06.12: One Byte Explainer&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Explainer
&lt;/h2&gt;

&lt;p&gt;A fundamental question in computer science asking if every problem whose solution can be quickly verified (NP) can also be quickly solved (P). Solving this would revolutionize fields like cryptography, optimization, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Context
&lt;/h2&gt;

&lt;p&gt;The P vs NP Problem is one of the seven Millennium Prize Problems with a $1 million reward for a correct solution, highlighting its significance in theoretical computer science and practical applications.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>cschallenge</category>
      <category>computerscience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Comprehensive Guide to Big O Notation and Efficient Coding Practices with Examples</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Wed, 19 Jun 2024 09:08:15 +0000</pubDate>
      <link>https://dev.to/sanukhandev/a-comprehensive-guide-to-big-o-notation-and-efficient-coding-practices-with-examples-44n2</link>
      <guid>https://dev.to/sanukhandev/a-comprehensive-guide-to-big-o-notation-and-efficient-coding-practices-with-examples-44n2</guid>
      <description>&lt;p&gt;In the world of software development, algorithms play a crucial role in solving complex problems efficiently. Whether you are preparing for a coding interview or working on real-world applications, a strong understanding of algorithms is essential. This article explores the basics of algorithms, their importance, and how to analyze their efficiency using the knapsack problem as a key example. We will also delve into the importance of time and space complexity in algorithm design, with detailed examples in JavaScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Algorithms
&lt;/h2&gt;

&lt;p&gt;An algorithm is essentially a sequence of steps designed to solve a specific problem. These steps need to be clear, unambiguous, and designed to handle the given input to produce the desired output. For developers, the ability to craft efficient algorithms is vital as it directly impacts the performance and scalability of the software they create.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Basic Algorithm for Finding Maximum Number&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's consider a simple algorithm to find the maximum number in an array of integers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initialize a variable &lt;code&gt;max&lt;/code&gt; with the first element of the array.&lt;/li&gt;
&lt;li&gt;Iterate through each element of the array.&lt;/li&gt;
&lt;li&gt;If the current element is greater than &lt;code&gt;max&lt;/code&gt;, update &lt;code&gt;max&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;After the loop ends, &lt;code&gt;max&lt;/code&gt; contains the maximum number.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's how this looks in JavaScript code:&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;findMax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&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;maxNum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="k"&gt;for &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;num&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;maxNum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;maxNum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;num&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;maxNum&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;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&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;findMax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 8&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This algorithm has a time complexity of O(n) because it requires a single pass through the array.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Knapsack Problem
&lt;/h2&gt;

&lt;p&gt;One classic example often used in interviews is the knapsack problem. In this problem, you are given a list of items, each with a value and a weight, and a bag that can carry a maximum weight. The objective is to select the items that maximize the total value without exceeding the bag's weight capacity. This problem not only tests your problem-solving skills but also your ability to write efficient code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Solving the Knapsack Problem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are different approaches to solve the knapsack problem, including:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Greedy Algorithm&lt;/strong&gt;: This approach works for the fractional knapsack problem but not for the 0/1 knapsack problem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dynamic Programming&lt;/strong&gt;: This is the most efficient approach for the 0/1 knapsack problem.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Dynamic Programming Solution:&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;knapsack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;weights&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;capacity&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;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;weights&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&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;dp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&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="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;capacity&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="nf"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

    &lt;span class="k"&gt;for &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;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;for &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;w&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;w&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;capacity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;w&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="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;w&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="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;dp&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="nx"&gt;w&lt;/span&gt;&lt;span class="p"&gt;]&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="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;weights&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;dp&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="nx"&gt;w&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&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="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="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;w&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;weights&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt; &lt;span class="nx"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;w&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;dp&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="nx"&gt;w&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;w&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="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;dp&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="nx"&gt;capacity&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;weights&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&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;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&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="mi"&gt;16&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;capacity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&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;knapsack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;weights&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;capacity&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// Output: 22&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This algorithm has a time complexity of O(n * capacity), which is efficient for reasonable input sizes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Time Complexity and Big O Notation ?
&lt;/h2&gt;

&lt;p&gt;To evaluate the efficiency of an algorithm, we use time complexity, which describes how the running time of an algorithm increases with the size of the input. Some common types of time complexities are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Linear Time (O(n))&lt;/strong&gt;: The running time increases linearly with the input size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Constant Time (O(1))&lt;/strong&gt;: The running time is constant regardless of the input size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logarithmic Time (O(log n))&lt;/strong&gt;: The running time increases logarithmically with the input size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quadratic Time (O(n²))&lt;/strong&gt;: The running time increases quadratically with the input size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exponential Time (O(2^n))&lt;/strong&gt;: The running time doubles with each additional element in the input.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Big O notation is a mathematical representation used to describe the upper bound of an algorithm's running time, helping developers compare the efficiency of different algorithms.&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Constant Time (O(1))&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getFirstElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&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;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This function always takes the same amount of time to execute, regardless of the array size.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Linear Time (O(n))&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sumArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&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;total&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="k"&gt;for &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;num&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;num&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;total&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;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The time it takes to execute this function increases linearly with the size of the input array.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Logarithmic Time (O(log n))&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;binarySearch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&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="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&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="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;right&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;mid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;right&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;target&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;mid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mid&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="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mid&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="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&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;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Binary search has a logarithmic time complexity because it divides the problem size in half with each iteration.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Quadratic Time (O(n²))&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;bubbleSort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&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;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;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;for &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;j&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;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&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="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&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;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
                &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
                &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&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="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;temp&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="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;arr&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;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The time it takes to execute bubble sort increases quadratically with the size of the input array.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Space Complexity ?
&lt;/h2&gt;

&lt;p&gt;Space complexity refers to the amount of memory an algorithm uses relative to the input size. Like time complexity, space complexity is also expressed using Big O notation. Understanding space complexity is crucial for designing algorithms that are not only fast but also memory efficient.&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Constant Space (O(1))&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;swap&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="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;temp&lt;/span&gt; &lt;span class="o"&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;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;temp&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;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This function uses a fixed amount of space regardless of the input size.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Linear Space (O(n))&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;duplicateArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&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;newArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;newArr&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;=&lt;/span&gt; &lt;span class="nx"&gt;arr&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;newArr&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;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This function uses additional space proportional to the size of the input array.&lt;/p&gt;

&lt;h2&gt;
  
  
  Importance of Using An Efficient Algorithm
&lt;/h2&gt;

&lt;p&gt;Efficient algorithms are critical for handling large inputs and ensuring that applications perform well under various conditions. As a developer, you need to be able to write optimized code and understand the trade-offs between different algorithmic approaches. This skill is particularly important in coding interviews, where demonstrating your ability to solve problems efficiently can set you apart from other candidates.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Thoughts on Algorithm Design
&lt;/h2&gt;

&lt;p&gt;Algorithms are the backbone of effective problem-solving in software development. Understanding how to design, analyze, and optimize algorithms is a fundamental skill for any developer. By mastering these concepts, you can improve your coding skills, perform better in interviews, and build more efficient and scalable software solutions.&lt;/p&gt;

&lt;p&gt;By delving deeper into these examples and practicing regularly, you can develop a solid foundation in algorithms, enabling you to tackle complex coding challenges with confidence.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>The Sliding Window Technique: A Powerful Algorithm for JavaScript Developers</title>
      <dc:creator>Sanu Khan</dc:creator>
      <pubDate>Tue, 11 Apr 2023 10:15:58 +0000</pubDate>
      <link>https://dev.to/sanukhandev/the-sliding-window-technique-a-powerful-algorithm-for-javascript-developers-3nfm</link>
      <guid>https://dev.to/sanukhandev/the-sliding-window-technique-a-powerful-algorithm-for-javascript-developers-3nfm</guid>
      <description>&lt;p&gt;As a JavaScript developer, you are constantly dealing with algorithms and data structures. One of the most useful techniques you can add to your toolkit is the sliding window technique. This technique is particularly useful for solving problems that involve arrays or strings. In this blog post, we will explore the sliding window technique, how it works, and how you can use it to solve real-world problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Sliding Window Technique?
&lt;/h2&gt;

&lt;p&gt;The sliding window technique is an algorithmic approach that involves iterating over a collection of items with a fixed-size window, where the window slides over the collection from left to right. The technique is particularly useful for solving problems that involve arrays or strings, where we need to find a subarray or substring that meets certain criteria.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does the Sliding Window Technique Work?
&lt;/h2&gt;

&lt;p&gt;The sliding window technique involves two pointers: one that points to the beginning of the window and another that points to the end of the window. We start by initializing both pointers to the first element in the collection. We then move the end pointer to the right, while keeping the start pointer fixed. Once the end pointer reaches a certain condition, we move the start pointer to the right and continue the process until we have exhausted the entire collection.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  How to Use the Sliding Window Technique in JavaScript
&lt;/h2&gt;

&lt;p&gt;The sliding window technique can be used to solve a wide range of problems in JavaScript. Here are some examples:&lt;/p&gt;

&lt;p&gt;The maximum sum of a subarray: Given an array of integers, find the subarray with the maximum sum.&lt;br&gt;
Longest substring without repeating characters: Given a string, find the longest substring that does not contain any repeating characters.&lt;br&gt;
Count of anagrams in a string: Given a string and a pattern, find the count of all anagrams in the pattern in the string.&lt;br&gt;
To implement the sliding window technique in JavaScript, you can use two pointers and a loop that iterates over the collection. You can also use additional variables to keep track of the current window and the maximum value.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

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

function maxSubarraySum(arr, num) {
  if (num &amp;gt; arr.length) {
    return null;
  }

  let maxSum = 0;
  let tempSum = 0;

  // initialize the window
  for (let i = 0; i &amp;lt; num; i++) {
    maxSum += arr[i];
  }

  tempSum = maxSum;

  // slide the window over the array
  for (let i = num; i &amp;lt; arr.length; i++) {
    tempSum = tempSum - arr[i - num] + arr[i];
    maxSum = Math.max(maxSum, tempSum);
  }

  return maxSum;
}

// example usage
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const num = 3;
const maxSum = maxSubarraySum(arr, num);
console.log(maxSum); // output: 24


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

&lt;/div&gt;

&lt;p&gt;In this example, the &lt;code&gt;maxSubarraySum&lt;/code&gt;the function takes an array of integers &lt;code&gt;arr&lt;/code&gt;and a number &lt;code&gt;num&lt;/code&gt;representing the length of the subarray we want to find. The function first checks if num is greater than the length of the array, and returns null if it is.&lt;/p&gt;

&lt;p&gt;The function then initializes the window by summing the first &lt;code&gt;num&lt;/code&gt;elements of the array. It also sets the tempSum variable to the initial &lt;code&gt;maxSum&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The function then iterates over the rest of the array, sliding the window over the array from left to right. For each window, it subtracts the leftmost element and adds the rightmost element to get the sum of the subarray. It then takes the maximum of the current &lt;code&gt;maxSum&lt;/code&gt;and the &lt;code&gt;tempSum&lt;/code&gt;, and updates the &lt;code&gt;maxSum&lt;/code&gt;accordingly.&lt;/p&gt;

&lt;p&gt;Finally, the function returns the &lt;code&gt;maxSum&lt;/code&gt;as the result.&lt;/p&gt;

&lt;p&gt;In this example, the input array is &lt;code&gt;[1, 2, 3, 4, 5, 6, 7, 8, 9]&lt;/code&gt;and the length of the subarray we want to find is &lt;code&gt;3&lt;/code&gt;. The function returns the maximum sum of any subarray of length &lt;code&gt;3&lt;/code&gt;, which is &lt;code&gt;24&lt;/code&gt; in this case.&lt;/p&gt;

&lt;p&gt;We can use this technique for several real-world problems such as :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Image processing: Suppose you have a stream of image data that needs to be processed in real-time. You can use the sliding window technique to process the image data in small windows, which can improve the efficiency of your image processing algorithms.&lt;/li&gt;
&lt;li&gt;Log analysis: Suppose you have a large log file containing millions of lines of data. You want to analyze the log data to find patterns or errors. You can use the sliding window technique to analyze the log data in small windows, which can help you identify patterns or errors more efficiently.&lt;/li&gt;
&lt;li&gt;Real-time data streaming: Suppose you have a real-time data streaming application that needs to process data in real time. You can use the sliding window technique to process the data in small windows, which can help you analyze the data more efficiently and respond to changes in the data stream more quickly.&lt;/li&gt;
&lt;li&gt;Video streaming: Suppose you have a video streaming application that needs to stream video data in real time. You can use the sliding window technique to process the video data in small windows, which can improve the efficiency of your video streaming algorithms.&lt;/li&gt;
&lt;li&gt;Network traffic monitoring: Suppose you have a network monitoring application that needs to monitor network traffic in real time. You can use the sliding window technique to monitor the network traffic in small windows, which can help you detect network anomalies or security threats more efficiently.&lt;/li&gt;
&lt;li&gt;These are just a few examples of how developers can use the sliding window technique to solve real-world problems. The technique is versatile and can be applied to many different types of problems that involve real-time data processing, log analysis, network monitoring, and more.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>node</category>
      <category>api</category>
    </item>
  </channel>
</rss>
