<?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: Nupur</title>
    <description>The latest articles on DEV Community by Nupur (@nupur_773).</description>
    <link>https://dev.to/nupur_773</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4240832%2Ffeb08254-d003-4a01-9035-27481a546a0f.png</url>
      <title>DEV Community: Nupur</title>
      <link>https://dev.to/nupur_773</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nupur_773"/>
    <language>en</language>
    <item>
      <title>Read your React components bottom-up (the JSX is the promise)</title>
      <dc:creator>Nupur</dc:creator>
      <pubDate>Fri, 04 Dec 2026 11:41:38 +0000</pubDate>
      <link>https://dev.to/solitaireinfosystems2011/read-your-react-components-bottom-up-the-jsx-is-the-promise-520k</link>
      <guid>https://dev.to/solitaireinfosystems2011/read-your-react-components-bottom-up-the-jsx-is-the-promise-520k</guid>
      <description>&lt;h1&gt;
  
  
  Read React Components Bottom-Up: A Simple Habit That Makes Debugging Faster
&lt;/h1&gt;

&lt;p&gt;Most of us read a component the way we read a book: top to bottom.&lt;/p&gt;

&lt;p&gt;Imports, then props, then state, then effects, then, 80 lines later, the JSX.&lt;/p&gt;

&lt;p&gt;By the time you reach the &lt;code&gt;return&lt;/code&gt;, you're holding a pile of variables with no idea what they're for.&lt;/p&gt;

&lt;p&gt;At &lt;strong&gt;Solitaire Infosystems&lt;/strong&gt;, a software development company in Mohali, our React and Next.js interns start with reading, not building. The first habit we teach is to read a component &lt;strong&gt;bottom-up&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here's how it works.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Idea
&lt;/h2&gt;

&lt;p&gt;The JSX at the bottom is the promise: this is what the user will see, and these are the things they can do.&lt;/p&gt;

&lt;p&gt;Everything above the &lt;code&gt;return&lt;/code&gt; exists only to keep that promise.&lt;/p&gt;

&lt;p&gt;So start at the &lt;code&gt;return&lt;/code&gt; and work upward. Every time you hit an identifier, ask one question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where does this come from?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A Small Example
&lt;/h2&gt;

&lt;p&gt;Let's look at a simple React component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"react"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;ProductList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;onSelect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setQuery&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;sortBy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setSortBy&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"price"&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="n"&gt;visible&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&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="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&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="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;sortBy&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;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;sortBy&lt;/span&gt;&lt;span class="p"&gt;]&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="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="nf"&gt;useEffect&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sb"&gt;`${visible.length} products`&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="n"&gt;visible&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;section&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;
        &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;target&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="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Search products"&lt;/span&gt;
      &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;sortBy&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setSortBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;target&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="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"price"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nc"&gt;Price&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;option&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;option&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;option&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;visible&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;p&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="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt; &lt;span class="n"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;onSelect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&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="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; · ₹&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;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="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;section&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Now Read It Bottom-Up
&lt;/h2&gt;

&lt;p&gt;Start at the &lt;code&gt;return&lt;/code&gt; and list what it uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;query&lt;/code&gt; and &lt;code&gt;setQuery&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;sortBy&lt;/code&gt; and &lt;code&gt;setSortBy&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;visible&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;onSelect&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The fields &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;name&lt;/code&gt;, and &lt;code&gt;price&lt;/code&gt; on each product&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now trace each one upward:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;onSelect and products are props.&lt;/strong&gt; The parent owns them; this component can only read them or call the callback.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;query and sortBy are state.&lt;/strong&gt; They're the only things this component remembers, and the user changes them through the two handlers in the JSX.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;visible is derived.&lt;/strong&gt; It's computed from &lt;code&gt;products&lt;/code&gt;, &lt;code&gt;query&lt;/code&gt;, and &lt;code&gt;sortBy&lt;/code&gt; on every render and stored nowhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The effect syncs something outside React.&lt;/strong&gt; Here, it updates the browser tab title based on what's on screen.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In about 30 seconds, you know what the component renders, what it needs from its parent, what it remembers, and what it does to the outside world.&lt;/p&gt;

&lt;p&gt;You never had to read it top-down.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three Things This Habit Catches
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. State That Should Be Derived
&lt;/h3&gt;

&lt;p&gt;A common beginner pattern is to keep &lt;code&gt;visible&lt;/code&gt; in state and update it with an effect whenever &lt;code&gt;query&lt;/code&gt; changes.&lt;/p&gt;

&lt;p&gt;Reading bottom-up, you see that &lt;code&gt;visible&lt;/code&gt; can always be computed from values you already have.&lt;/p&gt;

&lt;p&gt;Storing it adds an extra render and gives the two copies a chance to drift apart.&lt;/p&gt;

&lt;p&gt;The React documentation makes the same point in &lt;a href="https://react.dev/learn/you-might-not-need-an-effect" rel="noopener noreferrer"&gt;You Might Not Need an Effect&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Dead Weight
&lt;/h3&gt;

&lt;p&gt;If a variable above the &lt;code&gt;return&lt;/code&gt; isn't used by the JSX, a handler, or an effect the JSX triggers, you can probably delete it.&lt;/p&gt;

&lt;p&gt;Bottom-up reading finds these in seconds.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Components That Do Too Much
&lt;/h3&gt;

&lt;p&gt;If you can't say in one sentence what the JSX promises, the component is probably doing two jobs.&lt;/p&gt;

&lt;p&gt;Split it first, then clean up the logic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It on Your Own Code
&lt;/h2&gt;

&lt;p&gt;Pick one component from your current project and read it bottom-up.&lt;/p&gt;

&lt;p&gt;Then write one comment above the &lt;code&gt;return&lt;/code&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This component promises ___.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If the sentence needs the word "and" twice, that's your next refactor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where This Comes From
&lt;/h2&gt;

&lt;p&gt;We run this as a component walkthrough in the React JS and Next.js track at &lt;strong&gt;Solitaire Infosystems&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Interns read real components out loud, bottom-up, before they're allowed to change one.&lt;/p&gt;

&lt;p&gt;It sounds slow, but it makes them faster at debugging, reviewing, and getting productive in an unfamiliar codebase.&lt;/p&gt;

&lt;p&gt;If you'd like to learn React this way, explore our &lt;a href="https://solitaireinfosystems.com/react-js-course-in-chandigarh/" rel="noopener noreferrer"&gt;React JS course in Chandigarh&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;How do you read a new component: top-down or bottom-up? Tell us in the comments!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>AI vs ML: Same Problem, Two Approaches</title>
      <dc:creator>Nupur</dc:creator>
      <pubDate>Mon, 30 Nov 2026 11:54:24 +0000</pubDate>
      <link>https://dev.to/solitaireinfosystems2011/ai-vs-ml-same-problem-two-approaches-3gm9</link>
      <guid>https://dev.to/solitaireinfosystems2011/ai-vs-ml-same-problem-two-approaches-3gm9</guid>
      <description>&lt;p&gt;&lt;strong&gt;Artificial Intelligence is the goal: software that handles tasks which normally need human judgment. Machine Learning is one way to reach that goal: instead of writing the rules yourself, you give the program examples and it learns the pattern.&lt;/strong&gt; All ML is AI, but not all AI is ML.&lt;/p&gt;

&lt;p&gt;Definitions only get you so far, though. The quickest way to feel the difference is to solve one small problem both ways, so that's what this post does.&lt;/p&gt;

&lt;p&gt;I work with the R&amp;amp;D team at Solitaire Infosystems, a software development company in Mohali that also runs IT training and internship programs. This is one of the first exercises we give interns in our &lt;a href="https://solitaireinfosystems.com/machine-learning-course-in-chandigarh/" rel="noopener noreferrer"&gt;machine learning training in Chandigarh and Mohali&lt;/a&gt;, because it shows the trade-off better than any slide.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Artificial Intelligence (AI)&lt;/strong&gt; is the broad goal: making software do things that normally need human judgment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Machine Learning (ML)&lt;/strong&gt; is one way to get there: the program learns rules from examples instead of you writing them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deep Learning&lt;/strong&gt; is a subset of ML that uses neural networks with many layers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A chess program that only searches moves, or a hand-written expert system, is AI without any learning at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  The project: an enquiry sorter
&lt;/h2&gt;

&lt;p&gt;Imagine an internship page that gets messages like "what will it cost me?". We want to sort each message into one of three labels: &lt;code&gt;fees&lt;/code&gt;, &lt;code&gt;duration&lt;/code&gt; or &lt;code&gt;eligibility&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Approach 1: Rule-based (AI, no ML)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;RULES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"fees"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"fee"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"fees"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"duration"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"duration"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"long"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"eligibility"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"eligible"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"eligibility"&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;def&lt;/span&gt; &lt;span class="nf"&gt;rule_based&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;words&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&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="nf"&gt;split&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="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;keywords&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;RULES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&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;if&lt;/span&gt; &lt;span class="nb"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;words&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;keywords&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"unknown"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You wrote every rule. It's predictable and easy to debug, but it only knows what you thought of in advance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Approach 2: Machine Learning
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;feature_extraction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;TfidfVectorizer&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;linear_model&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sklearn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pipeline&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;make_pipeline&lt;/span&gt;

&lt;span class="n"&gt;train&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="s2"&gt;"what is the fee for the internship"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"fees"&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="s2"&gt;"how much do I need to pay"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"fees"&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="s2"&gt;"is there any registration fee"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"fees"&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="s2"&gt;"can I pay in installments"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"fees"&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="s2"&gt;"what is the total cost of the program"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"fees"&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="s2"&gt;"do you charge anything for the course"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"fees"&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="s2"&gt;"how long is the internship"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"duration"&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="s2"&gt;"what is the duration of the training"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"duration"&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="s2"&gt;"how many months does it run"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"duration"&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="s2"&gt;"when does the next batch start and end"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"duration"&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="s2"&gt;"is it six weeks or six months"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"duration"&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="s2"&gt;"how many hours per day are the classes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"duration"&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="s2"&gt;"who can apply for this internship"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"eligibility"&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="s2"&gt;"am I eligible if I am in final year"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"eligibility"&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="s2"&gt;"do I need prior coding knowledge"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"eligibility"&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="s2"&gt;"can a BCA student join"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"eligibility"&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="s2"&gt;"is this open for diploma students"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"eligibility"&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="s2"&gt;"what qualification is required"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"eligibility"&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="no"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;train&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;model&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;make_pipeline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nc"&gt;TfidfVectorizer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ngram_range&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nc"&gt;LogisticRegression&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_iter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&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="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"what will it cost me"&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="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="c1"&gt;# fees&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here you wrote no keyword rules. &lt;code&gt;TfidfVectorizer&lt;/code&gt; turns each sentence into numbers based on which words and word pairs it contains, and &lt;code&gt;LogisticRegression&lt;/code&gt; learns which of those numbers point to which label.&lt;/p&gt;

&lt;h2&gt;
  
  
  Head to head
&lt;/h2&gt;

&lt;p&gt;I tested both on six messages worded differently from the training data:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Message&lt;/th&gt;
&lt;th&gt;Truth&lt;/th&gt;
&lt;th&gt;Rule-based&lt;/th&gt;
&lt;th&gt;ML&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;what will it cost me&lt;/td&gt;
&lt;td&gt;fees&lt;/td&gt;
&lt;td&gt;unknown&lt;/td&gt;
&lt;td&gt;fees&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;how long will this take&lt;/td&gt;
&lt;td&gt;duration&lt;/td&gt;
&lt;td&gt;duration&lt;/td&gt;
&lt;td&gt;duration&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;can I join if I just finished 12th&lt;/td&gt;
&lt;td&gt;eligibility&lt;/td&gt;
&lt;td&gt;unknown&lt;/td&gt;
&lt;td&gt;eligibility&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;is the program paid or do I pay&lt;/td&gt;
&lt;td&gt;fees&lt;/td&gt;
&lt;td&gt;unknown&lt;/td&gt;
&lt;td&gt;fees&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;what is the fee&lt;/td&gt;
&lt;td&gt;fees&lt;/td&gt;
&lt;td&gt;fees&lt;/td&gt;
&lt;td&gt;fees&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;do I have to know python already&lt;/td&gt;
&lt;td&gt;eligibility&lt;/td&gt;
&lt;td&gt;unknown&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;fees&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Rule-based: 2 of 6. ML: 5 of 6.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What this shows
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;ML handles wording you never listed.&lt;/strong&gt; "Cost" and "pay" both appear in the fee examples, so the model linked "what will it cost me" and "do I pay" to &lt;code&gt;fees&lt;/code&gt;. The rule-based version only fires on the exact words in &lt;code&gt;RULES&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ML fails too, and quietly.&lt;/strong&gt; The last row is wrong. The rule-based bot said &lt;code&gt;unknown&lt;/code&gt;, which at least admits it doesn't know. The model gave a confident wrong answer, because 18 examples aren't enough to separate "know python" from the fee questions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data quality sets the ceiling.&lt;/strong&gt; The fix isn't a fancier algorithm. It's more varied examples of eligibility questions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A caveat: six test messages is a demo, not a benchmark. In real projects you hold out a proper test set with &lt;a href="https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html" rel="noopener noreferrer"&gt;train_test_split&lt;/a&gt; and measure on hundreds of examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  When should you use rules, and when ML?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Rules are fine when the logic is small, fixed and must be explainable, such as validating a form field.&lt;/li&gt;
&lt;li&gt;ML is worth it when the patterns are too varied to write down, such as free-text messages or images.&lt;/li&gt;
&lt;li&gt;Many production systems combine both: ML for the fuzzy part, rules for the hard constraints.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it yourself
&lt;/h2&gt;

&lt;p&gt;Don't stop at running my code. Write three messages you think will fool the model, run them, then add them to the training set with the right labels. Retrain and check whether it learned. That loop of break it, label it, retrain is most of what junior ML work looks like.&lt;/p&gt;

&lt;p&gt;If you'd like developers reviewing your work while you practise this, that's what interns do in the AI and ML program at &lt;a href="https://share.google/VpZ1s9JHqRL7WNeEk" rel="noopener noreferrer"&gt;Solitaire Infosystems, Mohali&lt;/a&gt;, offline or online through live sessions.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Find and Fix Memory Leaks in Flutter and React Native</title>
      <dc:creator>Nupur</dc:creator>
      <pubDate>Wed, 25 Nov 2026 11:41:12 +0000</pubDate>
      <link>https://dev.to/solitaireinfosystems2011/how-to-find-and-fix-memory-leaks-in-flutter-and-react-native-4hh0</link>
      <guid>https://dev.to/solitaireinfosystems2011/how-to-find-and-fix-memory-leaks-in-flutter-and-react-native-4hh0</guid>
      <description>&lt;p&gt;Memory leaks in Flutter and React Native happen when your app keeps references to objects it no longer needs. These could be controllers, timers, listeners or subscriptions that remain active even after a screen is closed.&lt;/p&gt;

&lt;p&gt;The result? Increasing memory usage, sluggish performance, UI freezes and unexpected crashes.&lt;/p&gt;

&lt;p&gt;The fix often comes down to one simple rule:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Whatever a screen starts, it must stop or dispose of when that screen goes away.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this guide, we'll explore how to identify memory leaks in Flutter and React Native, use Android debugging tools, and prevent common lifecycle-related issues.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Memory Leak in a Mobile App?
&lt;/h2&gt;

&lt;p&gt;Garbage collection removes objects that are no longer referenced by an application.&lt;/p&gt;

&lt;p&gt;A memory leak occurs when a long-lived object, such as a global variable, timer or subscription, continues referencing something that should have been removed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common Examples of Memory Leaks
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A screen closes, but its event listener remains registered.&lt;/li&gt;
&lt;li&gt;A timer continues running after its component is removed.&lt;/li&gt;
&lt;li&gt;A stream or event subscription is never cancelled.&lt;/li&gt;
&lt;li&gt;A singleton keeps a reference to an Activity, screen or BuildContext.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Memory Leak vs. Memory Bloat
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Memory Leak&lt;/th&gt;
&lt;th&gt;Memory Bloat&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Memory usage keeps increasing over repeated actions.&lt;/td&gt;
&lt;td&gt;Memory usage is high but relatively stable.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Objects remain referenced unnecessarily.&lt;/td&gt;
&lt;td&gt;Large resources consume excessive memory.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Requires proper cleanup and lifecycle management.&lt;/td&gt;
&lt;td&gt;Often requires resource optimisation.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can eventually cause crashes.&lt;/td&gt;
&lt;td&gt;Can slow down application performance.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What Are the Signs of a Memory Leak?
&lt;/h2&gt;

&lt;p&gt;Watch out for these warning signs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Memory usage increases every time you open and close the same screen.&lt;/li&gt;
&lt;li&gt;Screen transitions become progressively slower.&lt;/li&gt;
&lt;li&gt;The UI starts stuttering or freezing during long sessions.&lt;/li&gt;
&lt;li&gt;Android kills the application more frequently.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OutOfMemoryError&lt;/code&gt; appears in Logcat.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Usually Causes Memory Leaks in Flutter and React Native?
&lt;/h2&gt;

&lt;p&gt;Here are five common causes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Unremoved listeners:&lt;/strong&gt; Scroll, keyboard and app-state listeners remain active.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Uncancelled timers:&lt;/strong&gt; &lt;code&gt;Timer.periodic&lt;/code&gt; or &lt;code&gt;setInterval&lt;/code&gt; continues running unnecessarily.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Open subscriptions:&lt;/strong&gt; Streams, observers and event emitters are never cancelled.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unnecessary references:&lt;/strong&gt; Globals and singletons retain references to screens or their state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Large images and data:&lt;/strong&gt; Excessive resource consumption increases memory pressure.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Most of these problems come down to poor lifecycle management.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Find and Fix Memory Leaks in Flutter
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Compare Heap Snapshots Using Flutter DevTools
&lt;/h3&gt;

&lt;p&gt;Flutter DevTools provides useful memory profiling features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Profile Memory:&lt;/strong&gt; View current memory allocation by class.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Diff Snapshots:&lt;/strong&gt; Compare memory usage before and after an action.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trace Instances:&lt;/strong&gt; Identify where objects were allocated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Steps to identify a leak:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run your application on an Android device or emulator.&lt;/li&gt;
&lt;li&gt;Open Flutter DevTools and navigate to the Memory tab.&lt;/li&gt;
&lt;li&gt;Select Diff Snapshots.&lt;/li&gt;
&lt;li&gt;Capture a snapshot before opening the suspected screen.&lt;/li&gt;
&lt;li&gt;Open and close that screen five or six times.&lt;/li&gt;
&lt;li&gt;Capture another snapshot and compare the results.&lt;/li&gt;
&lt;li&gt;Check whether instances of the screen's State, controllers or custom classes continue increasing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use Trace Instances to investigate where those objects were created.&lt;/p&gt;

&lt;p&gt;Reference: Flutter DevTools Memory View.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Dispose Controllers in StatefulWidget
&lt;/h3&gt;

&lt;p&gt;A common Flutter mistake is creating a controller without disposing of it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Incorrect approach:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nf"&gt;_LoginScreenState&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;LoginScreen&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TextEditingController&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="nd"&gt;@override&lt;/span&gt;
  &lt;span class="nc"&gt;Widget&lt;/span&gt; &lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&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="nc"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;controller&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Correct approach:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nf"&gt;_LoginScreenState&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;LoginScreen&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TextEditingController&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="nd"&gt;@override&lt;/span&gt;
  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;dispose&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="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispose&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;super&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispose&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="nd"&gt;@override&lt;/span&gt;
  &lt;span class="nc"&gt;Widget&lt;/span&gt; &lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&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="nc"&gt;TextField&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;controller&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Apply the same principle to AnimationController, ScrollController, FocusNode and other disposable objects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember:&lt;/strong&gt; If your State creates an object, your State should dispose of it.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Cancel Stream Subscriptions
&lt;/h3&gt;

&lt;p&gt;Uncancelled subscriptions can retain references to the widget's State.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s1"&gt;'dart:async'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nf"&gt;_PriceTickerState&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;PriceTicker&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;late&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;StreamSubscription&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_subscription&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;_latest&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="nd"&gt;@override&lt;/span&gt;
  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;initState&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;super&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;initState&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="n"&gt;_subscription&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;widget&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setState&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_latest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&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="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;dispose&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="n"&gt;_subscription&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cancel&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;super&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispose&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="nd"&gt;@override&lt;/span&gt;
  &lt;span class="nc"&gt;Widget&lt;/span&gt; &lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&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;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'$_latest'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Calling &lt;code&gt;cancel()&lt;/code&gt; ensures the subscription no longer retains the screen through its callback.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Avoid Storing BuildContext in Long-Lived Objects
&lt;/h3&gt;

&lt;p&gt;Storing BuildContext inside a singleton, service or long-running callback can keep the widget tree reachable.&lt;/p&gt;

&lt;p&gt;Instead, retrieve the required values inside &lt;code&gt;build()&lt;/code&gt; and pass those values to other objects.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Detect Undisposed Objects Through Widget Tests
&lt;/h3&gt;

&lt;p&gt;Flutter developers can use the &lt;code&gt;leak_tracker_flutter_testing&lt;/code&gt; package to detect objects that are created but never disposed of.&lt;/p&gt;

&lt;p&gt;Add leak tracking to your widget tests and follow the package's current documentation for setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Find and Fix Memory Leaks in React Native
&lt;/h2&gt;

&lt;p&gt;React Native applications have two memory areas to consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;JavaScript heap (Hermes):&lt;/strong&gt; Stores components, state, closures and timers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Native Android heap:&lt;/strong&gt; Stores views, bitmaps and native modules.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both require separate debugging approaches.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Take JavaScript Heap Snapshots in React Native DevTools
&lt;/h3&gt;

&lt;p&gt;React Native 0.76 and later, when using Hermes, includes a Memory panel in React Native DevTools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Follow these steps:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start Metro and press &lt;code&gt;j&lt;/code&gt; to open React Native DevTools.&lt;/li&gt;
&lt;li&gt;Navigate to the Memory panel.&lt;/li&gt;
&lt;li&gt;Capture an initial heap snapshot.&lt;/li&gt;
&lt;li&gt;Open and close the suspected screen several times.&lt;/li&gt;
&lt;li&gt;Capture another snapshot.&lt;/li&gt;
&lt;li&gt;Switch to Comparison view.&lt;/li&gt;
&lt;li&gt;Search for component or class names and inspect the Retainers section.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Objects whose count continues increasing with every visit may indicate a memory leak.&lt;/p&gt;

&lt;p&gt;Reference: React Native DevTools.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Check Native Memory Using Android Studio Profiler
&lt;/h3&gt;

&lt;p&gt;Use Android Studio Profiler when investigating native memory issues.&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;Open your project's &lt;code&gt;android/&lt;/code&gt; folder in Android Studio.&lt;/li&gt;
&lt;li&gt;Run the application in debuggable mode.&lt;/li&gt;
&lt;li&gt;Select Track Memory Consumption to monitor Java/Kotlin allocations.&lt;/li&gt;
&lt;li&gt;Alternatively, choose Analyze Memory Usage to capture a heap dump.&lt;/li&gt;
&lt;li&gt;Inspect activity or fragment leaks and duplicate bitmaps.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Remember that JavaScript leaks may not appear as named objects in the native heap. Start with React Native DevTools when investigating component-level issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Always Return a Cleanup Function from useEffect
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Incorrect approach:&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="nf"&gt;useEffect&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;setInterval&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&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;"Running..."&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="mi"&gt;1000&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="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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Correct approach:&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="nf"&gt;useEffect&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;setInterval&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&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;"Running..."&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="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;clearInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;interval&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="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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The cleanup function runs when the component unmounts and before the effect runs again when its dependencies change.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Remove Event Listeners
&lt;/h3&gt;

&lt;p&gt;Always remove listeners when they are no longer required.&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="nf"&gt;useEffect&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;subscription&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;AppState&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s1"&gt;'change'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;handleAppStateChange&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;subscription&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&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="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="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Cancel Unnecessary Network Requests
&lt;/h3&gt;

&lt;p&gt;Use AbortController to prevent unnecessary requests from continuing after a component is removed or its URL changes.&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="nf"&gt;useEffect&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;controller&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;AbortController&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="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;signal&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="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&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;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;setData&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'AbortError'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;setError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abort&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="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prevents an outdated request from updating a screen the user has already left.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flutter vs React Native: Memory Leak Debugging Compared
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Debugging Area&lt;/th&gt;
&lt;th&gt;Flutter&lt;/th&gt;
&lt;th&gt;React Native&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Main memory tool&lt;/td&gt;
&lt;td&gt;Flutter DevTools&lt;/td&gt;
&lt;td&gt;React Native DevTools&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Native memory checks&lt;/td&gt;
&lt;td&gt;Android Studio Profiler&lt;/td&gt;
&lt;td&gt;Android Studio Profiler&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Snapshot comparison&lt;/td&gt;
&lt;td&gt;Diff Snapshots&lt;/td&gt;
&lt;td&gt;Comparison View&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Common culprit&lt;/td&gt;
&lt;td&gt;Undisposed controllers and subscriptions&lt;/td&gt;
&lt;td&gt;Missing useEffect cleanup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cleanup method&lt;/td&gt;
&lt;td&gt;&lt;code&gt;dispose()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;useEffect&lt;/code&gt; cleanup function&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Testing support&lt;/td&gt;
&lt;td&gt;leak_tracker&lt;/td&gt;
&lt;td&gt;Manual snapshot checks&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How to Prevent Memory Leaks in Mobile Applications
&lt;/h2&gt;

&lt;p&gt;Prevention is easier than debugging a memory problem after release.&lt;/p&gt;

&lt;p&gt;Follow these practical habits:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pair every start with a stop:&lt;/strong&gt; Every timer, listener and subscription needs a cleanup method.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dispose what you create:&lt;/strong&gt; Clean up controllers, focus nodes and animation objects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid unnecessary global references:&lt;/strong&gt; Keep screen-specific objects out of singletons.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Optimise image sizes:&lt;/strong&gt; Avoid loading full-resolution images for small thumbnails.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test repeated navigation:&lt;/strong&gt; Open and close important screens 10–20 times.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test on low-RAM devices:&lt;/strong&gt; Smaller devices can expose issues that flagship phones hide.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stop background activities:&lt;/strong&gt; Cancel unnecessary polling, timers and background tasks.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does garbage collection prevent memory leaks?
&lt;/h3&gt;

&lt;p&gt;No. Garbage collection only removes objects that are no longer referenced. If an active reference remains, the object stays in memory.&lt;/p&gt;

&lt;h3&gt;
  
  
  How can I distinguish a memory leak from normal memory growth?
&lt;/h3&gt;

&lt;p&gt;Repeat the same action several times. Normal memory usage generally stabilises, while a leak continues increasing without returning to a stable level.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is Android Studio Profiler enough for React Native?
&lt;/h3&gt;

&lt;p&gt;Not always. Android Studio Profiler is useful for native memory, while React Native DevTools helps identify JavaScript heap leaks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do all Flutter controllers need to be disposed of?
&lt;/h3&gt;

&lt;p&gt;Disposable objects created and owned by your State should be disposed of. If a parent provides the controller, the parent is responsible for its lifecycle.&lt;/p&gt;

&lt;h2&gt;
  
  
  The One Rule Every Mobile Developer Should Remember
&lt;/h2&gt;

&lt;p&gt;Memory leaks rarely appear immediately. They build up quietly during long application sessions, making them easy to overlook during basic testing.&lt;/p&gt;

&lt;p&gt;Take heap snapshots, inspect retained objects, test repeated navigation and clean up every resource properly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you start something, know exactly where it stops.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Written by &lt;a href="https://solitaireinfosystems.com/" rel="noopener noreferrer"&gt;Solitaire Infosystems&lt;/a&gt;, a software development company in Mohali that builds software solutions and provides practical IT training, industrial training and internship programmes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Learn. Build. Debug. Develop better applications with Solitaire Infosystems.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>reactnative</category>
      <category>android</category>
      <category>performance</category>
    </item>
    <item>
      <title>Manual vs Automation Testing: Which Should Beginners Learn First?</title>
      <dc:creator>Nupur</dc:creator>
      <pubDate>Wed, 18 Nov 2026 12:41:35 +0000</pubDate>
      <link>https://dev.to/solitaireinfosystems2011/manual-vs-automation-testing-which-should-beginners-learn-first-gk</link>
      <guid>https://dev.to/solitaireinfosystems2011/manual-vs-automation-testing-which-should-beginners-learn-first-gk</guid>
      <description>&lt;p&gt;If you’re choosing between manual vs automation testing as a beginner, start with manual testing. It teaches you what to test and why: writing test cases, spotting edge cases, reporting bugs clearly. Automation comes next, and it isn’t a shortcut. A script can only check what someone has already thought to check.&lt;br&gt;
Below: how the two compare, one login page tested both ways, and a learning order that doesn’t try to cram every tool at once.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is manual testing?
&lt;/h2&gt;

&lt;p&gt;Manual testing means a person checks how an application behaves by using it, without scripts. You act like a user, but with a plan: every action has an expected result, and you record it when the app does something else.&lt;br&gt;
On a shopping site, one manual test pass might cover:&lt;br&gt;
•Signing up with a new account&lt;br&gt;
•Logging in with valid and invalid credentials&lt;br&gt;
•Adding and removing cart items&lt;br&gt;
•Applying a valid coupon, expired or mistyped&lt;br&gt;
•Completing checkout&lt;br&gt;
Types you’ll hear about early on: functional, smoke, regression, exploratory and usability testing.&lt;br&gt;
What manual testing really builds is judgement. The tester who wonders “what happens if someone pastes a space before their email?” finds the bugs nobody wrote a test case for.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is automation testing?
&lt;/h2&gt;

&lt;p&gt;Automation testing uses code to run predefined test cases and compare the results with what’s expected. It pays off when the same checks have to run again and again, like re-testing login after every release.&lt;br&gt;
Beginners often mix up tools and frameworks, so here they are side by side:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;Used for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Selenium&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Browser automation library&lt;/td&gt;
&lt;td&gt;Web apps; works with Java, Python, C#, JavaScript and more&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Playwright&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Browser automation library&lt;/td&gt;
&lt;td&gt;Web apps on Chromium, Firefox and WebKit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Cypress&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;JavaScript testing tool&lt;/td&gt;
&lt;td&gt;Web apps, runs inside the browser&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Appium&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Mobile automation tool&lt;/td&gt;
&lt;td&gt;Android and iOS apps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TestNG / JUnit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Java test frameworks&lt;/td&gt;
&lt;td&gt;Organising, running and reporting tests, often with Selenium&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;pytest&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Python test framework&lt;/td&gt;
&lt;td&gt;The same job for Python test code&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  Manual vs automation testing: what’s the difference?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Manual testing&lt;/th&gt;
&lt;th&gt;Automation testing&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;How tests run&lt;/td&gt;
&lt;td&gt;A person performs each step&lt;/td&gt;
&lt;td&gt;Scripts perform the steps&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Coding needed&lt;/td&gt;
&lt;td&gt;No, to begin with&lt;/td&gt;
&lt;td&gt;Yes, in most setups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Speed on repeated checks&lt;/td&gt;
&lt;td&gt;Slow&lt;/td&gt;
&lt;td&gt;Fast once scripts exist&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Setup&lt;/td&gt;
&lt;td&gt;A test plan and the app&lt;/td&gt;
&lt;td&gt;Tools, a framework and a test environment&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strongest at&lt;/td&gt;
&lt;td&gt;Exploratory, usability and one-off checks&lt;/td&gt;
&lt;td&gt;Regression and repeated checks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Upkeep&lt;/td&gt;
&lt;td&gt;Test cases change when features change&lt;/td&gt;
&lt;td&gt;Scripts break when the UI changes and need fixing&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Automation doesn’t replace manual testing. Teams use both: scripts guard what already works, and people explore what’s new.&lt;/p&gt;
&lt;h2&gt;
  
  
  How do you test a login page manually and with automation?
&lt;/h2&gt;

&lt;p&gt;Manual scenarios&lt;br&gt;
•Valid username and password → the user lands on the dashboard&lt;br&gt;
•Wrong password → an error message appears&lt;br&gt;
•Empty username → a validation message appears&lt;br&gt;
•Badly formatted email → a warning appears&lt;br&gt;
Automating the first scenario with Python and Selenium 4&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;webdriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;common&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;by&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;By&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;webdriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;support&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ui&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;WebDriverWait&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;selenium&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;webdriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;support&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;expected_conditions&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="no"&gt;EC&lt;/span&gt;

&lt;span class="n"&gt;driver&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;webdriver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Chrome&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Selenium 4.6+ fetches the browser driver itself&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;driver&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="s2"&gt;"https://example.com/login"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# replace with your test app&lt;/span&gt;
    &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"testuser"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"password"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"correct-password"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;By&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"login-button"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;click&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# The real check: times out (fails) if no dashboard&lt;/span&gt;
    &lt;span class="nc"&gt;WebDriverWait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;driver&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="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;until&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;EC&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;url_contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/dashboard"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"PASS: valid login reaches the dashboard"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;finally&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;quit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The URL and element IDs are placeholders; inspect your own app for the real locators.&lt;br&gt;
Look at the wait line. That’s the test. Without it, the script would “pass” even when login fails, and that’s exactly why test design comes first: you can’t automate a check you haven’t defined.&lt;br&gt;
For waits and locators in more depth, the official Selenium documentation is the place to go.&lt;/p&gt;

&lt;h2&gt;
  
  
  In what order should beginners learn software testing?
&lt;/h2&gt;

&lt;p&gt;1.Testing fundamentals: SDLC, STLC, QA vs QC, the defect life cycle, verification vs validation.&lt;br&gt;
2.Manual testing practice: write test scenarios and test cases, and log bugs with clear steps to reproduce.&lt;br&gt;
3.Basic SQL: SELECT, WHERE, JOIN, INSERT and UPDATE, enough to check the data behind the UI.&lt;br&gt;
4.One programming language: Python or Java. Variables, loops, conditions, functions and OOP basics.&lt;br&gt;
5.One automation tool: Selenium or Playwright. Write small scripts that assert real results.&lt;br&gt;
6.API testing and Git: Postman for APIs; Git and GitHub to version your test code.&lt;br&gt;
7.Projects: test login, registration, cart and contact forms on practice sites, and put the work on GitHub.&lt;br&gt;
The most common mistake is jumping straight to step 5 because automation sounds more employable. People who skip test design end up with scripts that click through pages and check nothing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick answers
&lt;/h2&gt;

&lt;p&gt;Do I need coding for manual testing? No. You need it for automation, and basic SQL helps with both.&lt;br&gt;
Is manual testing still worth learning? Yes. Exploratory and usability testing still need people, and every automated test starts as a test case someone designed.&lt;br&gt;
Should I learn Selenium or Playwright first? Either works. Selenium has been around longer and has a lot of learning material; Playwright is newer and waits for elements automatically. Pick one and go deep before touching the other.&lt;br&gt;
How long before I can move to automation? It depends on how much you practise. A good signal is when you can write clear test cases and bug reports for a feature without help.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;A good tester isn’t someone who can run a test. It’s someone who knows what to test, why it matters and what could break. Build that first, then let scripts handle the repetition.&lt;br&gt;
Solitaire Infosystems is a software development and IT training company in Mohali. If you’re in the Tricity area and want guided, hands-on practice, see our &lt;a href="https://solitairelearning.com/course-detail/software-testing" rel="noopener noreferrer"&gt;software testing training&lt;/a&gt;&lt;/p&gt;

</description>
      <category>testing</category>
      <category>beginners</category>
      <category>selenium</category>
      <category>career</category>
    </item>
    <item>
      <title>7 Free Cybersecurity Labs for Beginners (No Home Lab Needed)</title>
      <dc:creator>Nupur</dc:creator>
      <pubDate>Tue, 17 Nov 2026 12:13:47 +0000</pubDate>
      <link>https://dev.to/solitaireinfosystems2011/7-free-cybersecurity-labs-for-beginners-no-home-lab-needed-1idm</link>
      <guid>https://dev.to/solitaireinfosystems2011/7-free-cybersecurity-labs-for-beginners-no-home-lab-needed-1idm</guid>
      <description>&lt;p&gt;You can start practising cybersecurity today without building a home lab. Free cybersecurity labs like TryHackMe, PortSwigger Web Security Academy, OverTheWire and picoCTF give you ready-made, legal targets. Most need only a browser. A couple need an SSH client or one Docker command.&lt;br&gt;
That matters because a lot of beginners lose their first month to VirtualBox errors and broken Kali installs. Building a lab is a useful skill. It just isn’t the first one you need.&lt;br&gt;
Below are seven platforms: what each is good for, where to start and the catch with each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What do you need before you start?
&lt;/h2&gt;

&lt;p&gt;•A modern browser. Enough for most of this list.&lt;br&gt;
•A terminal with SSH. Built into macOS, Linux and Windows 10/11. Needed for OverTheWire.&lt;br&gt;
•Docker. Only if you want to run OWASP Juice Shop.&lt;br&gt;
•A notes file. Seriously. You’ll need it more than any tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. TryHackMe: guided rooms for complete beginners
&lt;/h2&gt;

&lt;p&gt;TryHackMe teaches through short guided lessons called “rooms”. Each room explains a concept and then gives you a machine to practise on. Its AttackBox is a Linux machine that runs inside your browser, so you don’t need a local VM.&lt;br&gt;
Start with: the free introductory rooms on Linux, networking and web basics.&lt;br&gt;
The catch: free accounts get the AttackBox for one hour a day, and many full learning paths are paid. You can also connect your own machine over OpenVPN for free, but that brings back some setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. PortSwigger Web Security Academy: the deep end of web security
&lt;/h2&gt;

&lt;p&gt;PortSwigger Web Security Academy comes from the team behind Burp Suite and is free. Every topic starts with a written explanation and then gives you labs at three levels: Apprentice, Practitioner and Expert.&lt;br&gt;
It covers SQL injection, cross-site scripting (XSS), CSRF, SSRF, broken access control and authentication flaws in more depth than most paid courses.&lt;br&gt;
Start with: the SQL injection Apprentice labs.&lt;br&gt;
The catch: you can solve the early labs in a browser. Most Practitioner labs expect you to use Burp Suite Community Edition (free, but it needs installing).&lt;/p&gt;

&lt;h2&gt;
  
  
  3. OverTheWire Bandit: Linux skills, one level at a time
&lt;/h2&gt;

&lt;p&gt;OverTheWire runs “wargames” you play over SSH. In Bandit, the beginner game, the password for each level is hidden somewhere on the server. You find it with commands like ls, find, grep and cat, and along the way you learn file permissions and SSH keys.&lt;br&gt;
Your first command:&lt;br&gt;
ssh &lt;a href="mailto:bandit0@bandit.labs.overthewire.org"&gt;bandit0@bandit.labs.overthewire.org&lt;/a&gt; -p 2220&lt;/p&gt;

&lt;p&gt;The catch: it isn’t browser-based. You need a terminal, but no VM.&lt;br&gt;
If you only pick one platform from this list, pick Bandit. Almost every other platform assumes you can move around a Linux shell without thinking about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. picoCTF: Capture The Flag, built for learners
&lt;/h2&gt;

&lt;p&gt;picoCTF was created by security experts at Carnegie Mellon University. Its practice area, picoGym, keeps past challenges open all year in categories like General Skills, Web Exploitation, Cryptography, Forensics, Reverse Engineering and Binary Exploitation. It also includes a browser-based webshell, so you can run Linux commands without installing anything.&lt;br&gt;
Start with: General Skills, then Web Exploitation.&lt;br&gt;
The catch: the difficulty climbs fast in binary exploitation and reverse engineering. Don’t judge yourself by those categories in week one.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. CyberDefenders: the defender’s side
&lt;/h2&gt;

&lt;p&gt;CyberDefenders flips the usual CTF. You don’t break into a machine. You get evidence from an incident, such as network captures, logs or memory and disk images, and answer investigation questions like a SOC analyst would. It’s the most realistic free introduction to digital forensics and incident response on this list.&lt;br&gt;
The catch: only part of the lab library is free (the rest needs a Pro plan). Some labs run in the browser, while others mean downloading the evidence and opening it in tools like Wireshark. Save it for after you’re comfortable with Linux and networking basics.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. OWASP Juice Shop: a whole vulnerable online shop
&lt;/h2&gt;

&lt;p&gt;OWASP Juice Shop is an intentionally insecure web shop. It contains flaws from across the OWASP Top Ten and has a hidden scoreboard that tracks the challenges you solve. It feels closer to testing a real application than one-bug-per-page labs do.&lt;br&gt;
Run it locally (no VM, just Docker):&lt;br&gt;
docker run --rm -p 127.0.0.1:3000:3000 bkimminich/juice-shop&lt;/p&gt;

&lt;p&gt;Then open &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; in your browser.&lt;br&gt;
The catch: you need Docker or Node.js on your machine. The public demo instance is only a preview, and the project asks people not to attack it. Always hack your own copy.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Google Gruyere: a quick web security warm-up
&lt;/h2&gt;

&lt;p&gt;Google Gruyere is a small, deliberately buggy web app from Google, built as a codelab. When you start, it gives you your own sandboxed instance. It walks you through XSS, CSRF, information disclosure and similar bugs, with hints and an explanation of how to fix each one.&lt;br&gt;
The catch: it’s older and much smaller than modern apps. Treat it as a warm-up before PortSwigger or Juice Shop, not as a replacement for them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which free cybersecurity lab should you choose?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Platform&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;th&gt;Runs in&lt;/th&gt;
&lt;th&gt;Free-plan catch&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;TryHackMe&lt;/td&gt;
&lt;td&gt;Complete beginners, guided learning&lt;/td&gt;
&lt;td&gt;Browser (AttackBox) or VPN&lt;/td&gt;
&lt;td&gt;AttackBox 1 hr/day; many paths paid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PortSwigger Academy&lt;/td&gt;
&lt;td&gt;Web application security&lt;/td&gt;
&lt;td&gt;Browser + Burp Suite CE&lt;/td&gt;
&lt;td&gt;Later labs need Burp installed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OverTheWire Bandit&lt;/td&gt;
&lt;td&gt;Linux command line&lt;/td&gt;
&lt;td&gt;Terminal over SSH&lt;/td&gt;
&lt;td&gt;Not browser-based&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;picoCTF&lt;/td&gt;
&lt;td&gt;CTF-style problem solving&lt;/td&gt;
&lt;td&gt;Browser + webshell&lt;/td&gt;
&lt;td&gt;Steep jump in harder categories&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CyberDefenders&lt;/td&gt;
&lt;td&gt;Blue team, forensics, incident response&lt;/td&gt;
&lt;td&gt;Browser or downloaded evidence&lt;/td&gt;
&lt;td&gt;Pro labs are paid&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OWASP Juice Shop&lt;/td&gt;
&lt;td&gt;Testing a full web app&lt;/td&gt;
&lt;td&gt;Docker/Node.js on your machine&lt;/td&gt;
&lt;td&gt;Local install needed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Gruyere&lt;/td&gt;
&lt;td&gt;Quick web-bug warm-up&lt;/td&gt;
&lt;td&gt;Browser&lt;/td&gt;
&lt;td&gt;Small, older app&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Not sure where to begin? Try this four-week order
&lt;/h2&gt;

&lt;p&gt;•Week 1: OverTheWire Bandit, levels 0 to 10. Get comfortable in the terminal.&lt;br&gt;
•Week 2: TryHackMe free rooms on networking and web basics.&lt;br&gt;
•Week 3: PortSwigger SQL injection and XSS Apprentice labs.&lt;br&gt;
•Week 4: picoCTF General Skills and Web Exploitation, plus one free CyberDefenders lab if the defensive side interests you.&lt;br&gt;
Juice Shop and Gruyere fit in whenever you want a break from structured lessons.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you turn lab practice into real skill?
&lt;/h2&gt;

&lt;p&gt;Finishing challenges isn’t the same as learning from them. These are the habits that make the difference, and the mistakes beginners make most often:&lt;br&gt;
1.Don’t open the walkthrough after five minutes. Give yourself a fixed block (30–45 minutes) before you check hints. Being stuck is where most of the learning happens.&lt;br&gt;
2.Write down the root cause, not just the payload. After each lab, finish this sentence: “This worked because the app…”&lt;br&gt;
3.Learn the fix. For every vulnerability, note how a developer would prevent it: parameterised queries, output encoding, proper access checks. Interviewers ask about this side more often than beginners expect.&lt;br&gt;
4.Keep notes you can reuse. One Markdown file per platform, with commands, tools and the mistakes you made. Over time it becomes your personal cheat sheet.&lt;br&gt;
5.Build a small portfolio, honestly. Publish write-ups only where the platform allows it (many ask you not to share solutions to active challenges). Label them as training labs, not professional security work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Are free labs enough to learn cybersecurity?
&lt;/h2&gt;

&lt;p&gt;They’re enough to start and to find out which side of security you enjoy: offensive, web or defensive. They won’t teach you everything on their own. Most learners still need structured study of networking, Linux administration and security concepts, plus someone to review their work and point out gaps. Use the labs to practise what you study, not instead of studying.&lt;/p&gt;

&lt;h2&gt;
  
  
  Over to you
&lt;/h2&gt;

&lt;p&gt;Which of these free cybersecurity labs did you try first, and where did you get stuck? If you know another free platform where beginners can practise without building a lab, share it in the comments.&lt;br&gt;
Security reminder: only test systems you own or are explicitly allowed to test, such as these labs and intentionally vulnerable apps. Never try these techniques on real websites, networks or applications without written permission.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>cybersecurity</category>
      <category>security</category>
    </item>
    <item>
      <title>AI Is Your Pair Programmer, Not Your Brain: How to Code Smarter Without Losing Your Skills</title>
      <dc:creator>Nupur</dc:creator>
      <pubDate>Sat, 14 Nov 2026 10:46:22 +0000</pubDate>
      <link>https://dev.to/solitaireinfosystems2011/ai-is-your-pair-programmer-not-your-brain-how-to-code-smarter-without-losing-your-skills-5b4b</link>
      <guid>https://dev.to/solitaireinfosystems2011/ai-is-your-pair-programmer-not-your-brain-how-to-code-smarter-without-losing-your-skills-5b4b</guid>
      <description>&lt;p&gt;AI pair programming works best when you do the thinking and the AI does the assisting. Use ChatGPT, GitHub Copilot or Cursor to explain concepts, review your code and speed up repetitive work — but try the problem yourself first, question every suggestion, and never ship code you can’t explain.&lt;br&gt;
That sounds obvious. In practice it’s easy to slip. You paste a task, get 80 lines back, it runs, you move on. Do that for a few months and you get faster at prompting but slower at actually solving problems, which hurts most on the day the AI is confidently wrong.&lt;br&gt;
Here’s a workflow that keeps the speed without costing you the skill.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why shouldn’t you ask AI for the whole solution straight away?
&lt;/h2&gt;

&lt;p&gt;Say you need a login system. The tempting prompt is:&lt;br&gt;
“Create a complete login system using React and Node.js.”&lt;br&gt;
You’ll get plenty of code. But can you say where the password gets hashed, where the token is stored, or what happens after the fifth wrong password? If not, you now own code you can’t maintain or secure.&lt;br&gt;
Break the problem into questions first:&lt;br&gt;
•What does the login form need to collect, and how is it validated?&lt;br&gt;
•How are passwords hashed before they’re stored (bcrypt or Argon2, never plain text)?&lt;br&gt;
•How does the backend verify credentials and issue a token?&lt;br&gt;
•Where does the token live — an httpOnly cookie or localStorage — and what’s the trade-off?&lt;br&gt;
•What stops someone from brute-forcing the login?&lt;br&gt;
Then work through them with the AI one at a time. Each answer is something you understand and can check, instead of one big block you have to trust.&lt;/p&gt;
&lt;h2&gt;
  
  
  Should you try solving it yourself first?
&lt;/h2&gt;

&lt;p&gt;Yes, even if it’s only for ten minutes. A rough attempt tells you what you actually don’t know, which makes your next prompt much sharper.&lt;br&gt;
Take a simple task:&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="n"&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;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&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="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Find the sum of all numbers&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Write your own version first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;sum&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="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nb"&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="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 30&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now ask the AI something that builds on your work:&lt;br&gt;
“Explain how my loop works, then show me the same thing with reduce(). When would you pick one over the other?”&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="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&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;/div&gt;



&lt;p&gt;Now you’re comparing two approaches you understand, not copying one you don’t.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you get AI to teach you instead of just writing code?
&lt;/h2&gt;

&lt;p&gt;Change what you ask for. When the AI hands you a solution, don’t paste it in yet. Ask:&lt;br&gt;
•Why did you choose this approach?&lt;br&gt;
•What does each part do?&lt;br&gt;
•Is there a simpler version?&lt;br&gt;
•What happens if the input is empty or null?&lt;br&gt;
•Which edge cases could break it?&lt;br&gt;
•Will it still be fast with 100,000 items?&lt;br&gt;
Compare these two prompts. The first gets you code. The second gets you understanding:&lt;br&gt;
“Write a function to remove duplicate values from an array.”&lt;br&gt;
“Explain three ways to remove duplicates from a JavaScript array, compare their time complexity, and tell me when each one makes sense.”&lt;br&gt;
The second answer will usually cover new Set(), filter() with indexOf(), and reduce(), and explain why the Set version is the usual default for large arrays. That reasoning sticks with you long after the snippet is forgotten.&lt;/p&gt;
&lt;h2&gt;
  
  
  How should you use AI for debugging?
&lt;/h2&gt;

&lt;p&gt;Debugging is where the habit matters most. Pasting an error and applying whatever fix comes back works until the fix hides the real problem.&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;getUserName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;profile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nb"&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;getUserName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// TypeError: Cannot read properties of null (reading 'profile')&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don’t ask the AI to “fix this”. Ask:&lt;br&gt;
“Why does this throw a TypeError? Explain the root cause and give me two ways to handle it.”&lt;br&gt;
You’ll typically get two options:&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="c1"&gt;// Option 1: return a fallback if data is missing&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getUserName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;profile&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&gt;"Guest"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Option 2: fail loudly, because a missing user is a bug&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getUserName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;profile&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="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"getUserName: user profile is required"&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="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;profile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which one is right depends on whether a missing user is normal in your app or a sign that something upstream broke. That’s a judgment call the AI can’t make without knowing your codebase. Making it is your job.&lt;/p&gt;

&lt;h2&gt;
  
  
  What should you check before using AI-generated code?
&lt;/h2&gt;

&lt;p&gt;AI tools state wrong answers in the same confident tone as right ones. Common problems include logic that solves a slightly different problem, outdated methods, unnecessary packages, vague variable names, missing error handling and security holes. Run through this before you commit anything:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What to check&lt;/th&gt;
&lt;th&gt;Why it matters&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Logic&lt;/td&gt;
&lt;td&gt;Does it solve your actual problem, not a similar one?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Readability&lt;/td&gt;
&lt;td&gt;Could a teammate follow it without asking you?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;Does it hold up with larger inputs?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security&lt;/td&gt;
&lt;td&gt;Does it trust user input, leak data or store secrets badly?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dependencies&lt;/td&gt;
&lt;td&gt;Did it add a package you don’t need, or one that’s outdated?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Error handling&lt;/td&gt;
&lt;td&gt;What happens when the network, input or data fails?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Tests   Have you actually run it with different inputs?&lt;/p&gt;

&lt;h2&gt;
  
  
  Why should you write your own tests first?
&lt;/h2&gt;

&lt;p&gt;If the AI writes the code and the tests, it can make the same wrong assumption in both, and everything passes. Decide the test cases yourself first. For an isEven function:&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="nf"&gt;isEven&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nf"&gt;isEven&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="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// false&lt;/span&gt;
&lt;span class="nf"&gt;isEven&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;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nf"&gt;isEven&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="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// true&lt;/span&gt;
&lt;span class="nf"&gt;isEven&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;2.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ? decide this before the AI decides for you&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That last case is the useful one. Should it return false, or throw an error? Answering that is part of designing the function. Once your list is ready, ask:&lt;br&gt;
“Review these test cases and tell me which important scenarios I’ve missed.”&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you keep your coding skills sharp while using AI?
&lt;/h2&gt;

&lt;p&gt;Code without AI on purpose, regularly. One focused session a week is enough to notice what you can and can’t do on your own:&lt;br&gt;
•Solve one problem with no assistant open.&lt;br&gt;
•Build a small feature without code generation.&lt;br&gt;
•Debug an error using only the docs and your browser’s dev tools.&lt;br&gt;
•Write a common function from memory.&lt;br&gt;
•Rebuild an old project from scratch.&lt;br&gt;
The point isn’t to avoid AI. It’s to make sure you still can work without it when you need to, like in an interview or when a tool gets something subtly wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does a good AI pair programming workflow look like?
&lt;/h2&gt;

&lt;p&gt;1.Understand: Read the task and state the real problem in your own words.&lt;br&gt;
2.Plan: Sketch the steps before writing anything.&lt;br&gt;
3.Attempt: Write a first version yourself, even a rough one.&lt;br&gt;
4.Collaborate: Ask the AI to review it, explain concepts or suggest improvements.&lt;br&gt;
5.Verify: Run it, test edge cases, and read every line you’re keeping.&lt;br&gt;
6.Reflect: Make sure you could explain the final code to someone else.&lt;br&gt;
You stay in charge of the reasoning. The AI speeds up everything around it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bottom line
&lt;/h2&gt;

&lt;p&gt;Ignoring AI tools isn’t a smart move, and handing them every decision isn’t either. The developers who get the most from AI are the ones who question its suggestions, catch its mistakes and still make the technical calls themselves.&lt;br&gt;
So use it to explore new concepts, skip boilerplate and see other approaches, and keep practising the fundamentals: logic, debugging, data structures, algorithms and system design.&lt;br&gt;
A good AI pair programmer helps you write better code. A good developer knows why that code works.&lt;br&gt;
If you’re learning to code and want to build those fundamentals alongside modern tools, Solitaire Infosystems, a software development and IT training company in Mohali, offers practical, project-based training in MERN stack, React JS, Python and other technologies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Over to you
&lt;/h2&gt;

&lt;p&gt;How does AI fit into your coding day?&lt;br&gt;
•Do you ask it for complete solutions?&lt;br&gt;
•Do you mostly use it for debugging and code review?&lt;br&gt;
•Or do you try the problem yourself before opening an assistant?&lt;br&gt;
Share what works for you in the comments, especially any habits that have kept your skills sharp.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>5 Data Structure Mistakes Freshers Make in Production Code (and How to Fix Them)</title>
      <dc:creator>Nupur</dc:creator>
      <pubDate>Thu, 12 Nov 2026 11:10:05 +0000</pubDate>
      <link>https://dev.to/solitaireinfosystems2011/5-data-structure-mistakes-freshers-make-in-production-code-and-how-to-fix-them-20ll</link>
      <guid>https://dev.to/solitaireinfosystems2011/5-data-structure-mistakes-freshers-make-in-production-code-and-how-to-fix-them-20ll</guid>
      <description>&lt;p&gt;The data structure mistakes freshers make most often in production code are: using arrays for every lookup, ignoring time complexity, picking a structure that's slow at the operation you run most, copying large data inside loops, and skipping edge cases (including memory that never gets released). None of them show up in a 10-row test. All of them show up when real users arrive.&lt;br&gt;
A useful way to think about it: choosing a data structure is choosing which operations will be cheap. Pick it for the operation your code runs most often, not for the one you learned first.&lt;/p&gt;
&lt;h2&gt;
  
  
  Data structure mistakes at a glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mistake&lt;/th&gt;
&lt;th&gt;What breaks&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Arrays for repeated lookups&lt;/td&gt;
&lt;td&gt;Every lookup scans the list&lt;/td&gt;
&lt;td&gt;Index once with a &lt;code&gt;Map&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ignoring time complexity&lt;/td&gt;
&lt;td&gt;Hidden nested loops at scale&lt;/td&gt;
&lt;td&gt;Use a &lt;code&gt;Set&lt;/code&gt;, test with big data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wrong structure for the main operation&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;shift()&lt;/code&gt; on long queues&lt;/td&gt;
&lt;td&gt;Use a real queue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copying inside loops&lt;/td&gt;
&lt;td&gt;O(n²) time and memory churn&lt;/td&gt;
&lt;td&gt;Copy once, or not at all&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Skipping edge cases&lt;/td&gt;
&lt;td&gt;Crashes, leaks in long-running servers&lt;/td&gt;
&lt;td&gt;Guard inputs, bound caches&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h2&gt;
  
  
  1. Why is an array the wrong choice for frequent lookups?
&lt;/h2&gt;

&lt;p&gt;Arrays are the first structure most of us learn, so they become the default for everything. Here's a typical user lookup:&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="n"&gt;users&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;101&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Aman"&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="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;102&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Priya"&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="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;103&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Rahul"&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="c1"&gt;// O(n): may check every user before finding a match&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;u&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="mi"&gt;103&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run once, this is fine. Run inside a request handler, or for every item in another list, and you're scanning the whole array again and again. Build an index once instead:&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="c1"&gt;// Build once: O(n)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;usersById&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;u&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;u&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="c1"&gt;// Each lookup: O(1) on average&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;usersById&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="mi"&gt;103&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the &lt;code&gt;Map&lt;/code&gt; stores the whole user object, not just the name. Indexing by ID shouldn't cost you the rest of the record.&lt;br&gt;
How to avoid it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Before choosing, ask how the data will be read: in order, by position, or by key.&lt;/li&gt;
&lt;li&gt;Use arrays for ordered data you loop over or access by index.&lt;/li&gt;
&lt;li&gt;Use a &lt;code&gt;Map&lt;/code&gt; when you look things up by key more than a handful of times.&lt;/li&gt;
&lt;li&gt;If the data changes, update the &lt;code&gt;Map&lt;/code&gt; along with the array, or keep only the &lt;code&gt;Map&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  2. How does ignoring time complexity slow down your code?
&lt;/h2&gt;

&lt;p&gt;A function can be instant with 10 records and painfully slow with 100,000. Usually the cause is a loop you didn't notice you wrote.&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;hasCommonElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;arr2&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;const&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;arr1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&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="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="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;includes()&lt;/code&gt; is itself a loop. So this is a nested loop, O(n × m) in the worst case. With 10,000 items in each array, that's up to 100 million comparisons.&lt;br&gt;
A &lt;code&gt;Set&lt;/code&gt; turns the inner search into a constant-time check on average:&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;hasCommonElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;arr2&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="n"&gt;lookup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;arr1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;some&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;lookup&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's O(n + m) on average. You can see the difference yourself with fake data:&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="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100_000&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="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;i&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="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;100_000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// no overlap: worst case&lt;/span&gt;

&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;time&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hasCommonElement"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;hasCommonElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timeEnd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hasCommonElement"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How to avoid it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Know which built-in methods loop internally: &lt;code&gt;includes&lt;/code&gt;, &lt;code&gt;indexOf&lt;/code&gt;, &lt;code&gt;find&lt;/code&gt;, &lt;code&gt;filter&lt;/code&gt;, &lt;code&gt;splice&lt;/code&gt; and &lt;code&gt;shift&lt;/code&gt; are all O(n).&lt;/li&gt;
&lt;li&gt;Look for hidden nesting, such as &lt;code&gt;.includes()&lt;/code&gt; inside &lt;code&gt;.map()&lt;/code&gt; or &lt;code&gt;.filter()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Test with realistic sizes. Generating 100,000 fake records takes one line.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Which data structure should you use for the operations you run most?
&lt;/h2&gt;

&lt;p&gt;Every structure is fast at some operations and slow at others. A quick reference for JavaScript:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You need&lt;/th&gt;
&lt;th&gt;Use&lt;/th&gt;
&lt;th&gt;Watch out for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Access by position&lt;/td&gt;
&lt;td&gt;Array&lt;/td&gt;
&lt;td&gt;Inserting or deleting in the middle is O(n)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Last in, first out&lt;/td&gt;
&lt;td&gt;Array with &lt;code&gt;push&lt;/code&gt;/&lt;code&gt;pop&lt;/code&gt; (stack)&lt;/td&gt;
&lt;td&gt;Nothing major; both are fast&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First in, first out&lt;/td&gt;
&lt;td&gt;A queue&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;array.shift()&lt;/code&gt; is O(n)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unique values&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Set&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Objects are compared by reference, not content&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lookup by key&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Map&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Plain objects turn every key into a string&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The queue case catches a lot of freshers. A job processor that handles tasks in arrival order often looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Each shift() moves every remaining element down one slot&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;processJob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shift&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a few hundred jobs it rarely matters. For a long-running worker with a big backlog, it does. A small queue that moves a pointer instead of the elements:&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;class&lt;/span&gt; &lt;span class="nc"&gt;Queue&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  #&lt;span class="n"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  #&lt;span class="n"&gt;head&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="nf"&gt;enqueue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&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="nf"&gt;dequeue&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;head&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&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;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// let the old item be garbage-collected&lt;/span&gt;
    &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Compact now and then so the array doesn't grow forever&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;head&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;head&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;head&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;return&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;get&lt;/span&gt; &lt;span class="nf"&gt;size&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="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;#&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before picking a structure, ask:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Do I need fast lookups by key?&lt;/li&gt;
&lt;li&gt;Will I insert or delete often, and where: start, middle or end?&lt;/li&gt;
&lt;li&gt;Does order of processing matter?&lt;/li&gt;
&lt;li&gt;Do values need to be unique?&lt;/li&gt;
&lt;li&gt;How large can this data realistically get?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  4. When does copying data become a performance problem?
&lt;/h2&gt;

&lt;p&gt;Copying an array once is fine:&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="n"&gt;updatedUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newUser&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The problem is copying inside a loop. This pattern looks clean and shows up in a lot of fresher 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="c1"&gt;// Copies the whole accumulator on every pass: O(n²)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;activeUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;active&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;acc&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With 50,000 users, that's tens of thousands of ever-larger arrays created and thrown away. The fix is shorter:&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="n"&gt;activeUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;active&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same trap exists for objects. &lt;code&gt;{ ...acc, [u.id]: u }&lt;/code&gt; inside &lt;code&gt;reduce&lt;/code&gt; is also O(n²). Use &lt;code&gt;Object.fromEntries()&lt;/code&gt; or a &lt;code&gt;Map&lt;/code&gt; instead.&lt;br&gt;
Also worth knowing: spread makes a shallow copy. Nested objects are shared, so changing &lt;code&gt;copy[0].name&lt;/code&gt; changes the original too. &lt;code&gt;structuredClone()&lt;/code&gt; makes a deep copy, but it's expensive, so use it when you actually need independent nested data.&lt;br&gt;
How to avoid it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Never spread an accumulator inside &lt;code&gt;reduce&lt;/code&gt;, &lt;code&gt;map&lt;/code&gt; or a loop.&lt;/li&gt;
&lt;li&gt;Keep immutable updates in UI state (React, Redux), but copy once per update, not once per item.&lt;/li&gt;
&lt;li&gt;When something feels slow, profile it in Chrome DevTools before guessing.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  5. What edge cases break code in production?
&lt;/h2&gt;

&lt;p&gt;Test data is usually tidy. Production data isn't: empty lists, missing fields, duplicates, the wrong types.&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;getFirstUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;users&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;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pass an empty array and this throws, because &lt;code&gt;users[0]&lt;/code&gt; is &lt;code&gt;undefined&lt;/code&gt;. A safer version:&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;getFirstUserName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;users&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;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It returns &lt;code&gt;null&lt;/code&gt; rather than a string like &lt;code&gt;"No user found"&lt;/code&gt;. A placeholder string can end up rendered or saved as if it were a real name. Return "nothing" and let the caller decide what to show.&lt;br&gt;
Inputs worth testing every time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An empty array, &lt;code&gt;null&lt;/code&gt; and &lt;code&gt;undefined&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Exactly one item&lt;/li&gt;
&lt;li&gt;Duplicate values&lt;/li&gt;
&lt;li&gt;A very large input&lt;/li&gt;
&lt;li&gt;The wrong type, such as the string &lt;code&gt;"103"&lt;/code&gt; instead of the number &lt;code&gt;103&lt;/code&gt;. This one also bites &lt;code&gt;Map&lt;/code&gt; users: &lt;code&gt;usersById.get("103")&lt;/code&gt; won't find the key &lt;code&gt;103&lt;/code&gt;.
Memory is the other half. This cache looks harmless:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;profileCache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getUserProfile&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="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;profileCache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&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="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;profileCache&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="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;loadProfile&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="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="n"&gt;profileCache&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="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In a Node.js server that runs for weeks, it grows with every new ID and never shrinks. Give it a limit. A &lt;code&gt;Map&lt;/code&gt; remembers insertion order, so the first key is always the oldest:&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="no"&gt;MAX_ENTRIES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;cacheProfile&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;profile&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;profileCache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="no"&gt;MAX_ENTRIES&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="n"&gt;oldestKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;profileCache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&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="n"&gt;profileCache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;oldestKey&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="n"&gt;profileCache&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="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;profile&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your keys are objects whose lifetime you don't control, a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap" rel="noopener noreferrer"&gt;WeakMap&lt;/a&gt; lets entries disappear once nothing else references the key.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do these mistakes reach production?
&lt;/h2&gt;

&lt;p&gt;The pattern behind all five is the same: the code was only ever run on data the developer typed in by hand. Definitions and Big O tables are easy to memorise. Noticing a hidden loop in your own pull request is a different skill, and it mostly comes from writing real features and having someone review them.&lt;br&gt;
Solitaire Infosystems is a software development and IT training company in Mohali that runs job-oriented training in MERN stack, React JS, Python and other technologies, along with 6-week and 6-month industrial training and stipend-based internships. If you're in Mohali, Chandigarh or the wider Tricity and want guided practice on real projects, you can &lt;a href="https://www.solitaireinfosystems.com" rel="noopener noreferrer"&gt;see the current programs at Solitaire Infosystems&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick answers
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is the most common data structure mistake beginners make?&lt;/strong&gt;&lt;br&gt;
Using an array for repeated lookups by ID or key. Each &lt;code&gt;find()&lt;/code&gt; scans the list, so the cost grows with your data. A &lt;code&gt;Map&lt;/code&gt; built once gives average O(1) lookups.&lt;br&gt;
&lt;strong&gt;Is a Map faster than a plain object in JavaScript?&lt;/strong&gt;&lt;br&gt;
For data where keys are added and removed often, or keys aren't strings, &lt;code&gt;Map&lt;/code&gt; is usually the better fit. For a fixed shape like a config object, a plain object is fine.&lt;br&gt;
&lt;strong&gt;Do I need to learn every data structure before my first developer job?&lt;/strong&gt;&lt;br&gt;
No. Arrays, &lt;code&gt;Map&lt;/code&gt;, &lt;code&gt;Set&lt;/code&gt;, stacks, queues and basic Big O cover most day-to-day decisions in web development. Trees and graphs matter for specific problems and for interviews.&lt;br&gt;
&lt;strong&gt;How do I check if my JavaScript code is slow?&lt;/strong&gt;&lt;br&gt;
Use &lt;code&gt;console.time()&lt;/code&gt; for a rough number, and the Performance and Memory tabs in Chrome DevTools (or &lt;code&gt;node --inspect&lt;/code&gt;) when you need to see where the time or memory actually goes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;Code that works with ten records has passed the first test, not the last one. Good developers write code that works. Better developers know how it behaves when the data grows.&lt;br&gt;
Which of these have you shipped to production? Tell me in the comments, along with the one that took you longest to find.&lt;/p&gt;

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