<?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: Alexandra</title>
    <description>The latest articles on DEV Community by Alexandra (@ale3oula).</description>
    <link>https://dev.to/ale3oula</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%2F155897%2Fbd0b9c2b-1685-487f-9de3-5096a19ae2eb.png</url>
      <title>DEV Community: Alexandra</title>
      <link>https://dev.to/ale3oula</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ale3oula"/>
    <language>en</language>
    <item>
      <title>How Many Introductions Away Are You From Pedro Pascal? A Practical Introduction to Graph Search</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Tue, 11 Aug 2026 14:05:24 +0000</pubDate>
      <link>https://dev.to/ale3oula/how-many-introductions-away-are-you-from-pedro-pascal-a-practical-introduction-to-graph-search-5bfg</link>
      <guid>https://dev.to/ale3oula/how-many-introductions-away-are-you-from-pedro-pascal-a-practical-introduction-to-graph-search-5bfg</guid>
      <description>&lt;p&gt;I was watching The Mandalorian the other day when it struck me that I don't know Pedro Pascal, which is, by itself, very tragic.&lt;/p&gt;

&lt;p&gt;But maybe I know someone, who knows someone, who knows someone, ..., who knows Pedro Pascal. Somewhere out there, there is a finite chain of introductions that connects me to him. So the important computer science question we try to solve today is: How many introductions would it take to reach him?&lt;/p&gt;

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

&lt;p&gt;We accidentally have invented a graph problem!&lt;/p&gt;

&lt;h3&gt;
  
  
  Turn your social life into a graph
&lt;/h3&gt;

&lt;p&gt;Imagine that each person on this earth is a &lt;strong&gt;node&lt;/strong&gt; and any relationship or acquaintance between two people is an &lt;strong&gt;edge&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Alexandra ── Maria ── Sofia ── Pedro
    │
    └── John ── Elena ── Carlos

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

&lt;/div&gt;



&lt;p&gt;This is an unweighted and undirected graph.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Unweighted means that every connection counts the same. We don't care whether Maria is Sofia's best friend or someone she met once at a cafe.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Undirected means the relationship is both ways: if Alexandra knows Maria, Maria knows Alexandra.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we strip the fluff of the original question, it kinda changes from "How do I meet Pedro Pascal?" to  "Given an unweighted graph, what is the shortest path between node A and node B?", which if you are familiar with trees or graphs it sounds like a BFS (Breadth-First Search). &lt;/p&gt;

&lt;p&gt;In code, the simplest way to represent this kind of data is an &lt;strong&gt;adjacency list&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;graph&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;Alexandra&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Maria&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;Maria&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alexandra&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sofia&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;Sofia&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Maria&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Pedro&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;Pedro&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sofia&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;John&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alexandra&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Elena&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;Elena&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Carlos&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;Carlos&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Elena&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Make our delusions an algorithm
&lt;/h3&gt;

&lt;p&gt;Unfortunately, screaming “DOES ANYONE KNOW PEDRO PASCAL?” into the void isn't an algorithm. It has no order, no memory, and no stopping condition. If you just wander from person to person picking whoever seems interesting, you can easily do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Alexandra → Maria → Sofia → Maria → Sofia → Maria → ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because the graph is undirected, Maria connects back to Sofia and Sofia connects back to Maria. Without remembering who we met already, nothing stops us from revisiting the same people forever.&lt;/p&gt;

&lt;p&gt;So we basically need two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A rule for what order to explore people in.&lt;/li&gt;
&lt;li&gt;A way to remember who we already visited.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's where a queue and a visited set come in.&lt;/p&gt;

&lt;h3&gt;
  
  
  Breadth-first search explained
&lt;/h3&gt;

&lt;p&gt;The key observation for finding the shortest path is this: check everyone one connection away before checking anyone two connections away. This is breadth-first search, and it organizes the graph into levels:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Level 0        Alexandra
                  │
           ┌──────┴──────┐
Level 1   Maria          John
            │              │
Level 2   Sofia          Elena
            │
Level 3   PEDRO 🎉
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;BFS will check all my direct friends (level 1), if Pedro isn't there (🥲) will check the direct friends of my direct friends (level 2) and so on. The moment Pedro is found, you know that this is the shortest possible path, because every shorter one has already been checked.&lt;/p&gt;

&lt;h3&gt;
  
  
  Put everything together
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;introductionsAway&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;degrees&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="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;visited&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;Set&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;queue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;]]];&lt;/span&gt; 

  &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;queue&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="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="nx"&gt;friend&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;graph&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;visited&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="nx"&gt;friend&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;friend&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;degrees&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;friend&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;

      &lt;span class="nx"&gt;visited&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;friend&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;queue&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="nx"&gt;friend&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;friend&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="na"&gt;degrees&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="na"&gt;path&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;
  
  
  The twist: real relationships aren't equal
&lt;/h3&gt;

&lt;p&gt;So far in our problem knowing someone is binary. But you and I both know that's a lie. There's a biiiig  difference between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maria once stood next to Pedro at an event, and&lt;/li&gt;
&lt;li&gt;Pedro? Yeah, we're having dinner every Thursday.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Technically, both are relationships but practically, one of them is significantly more useful to my &lt;em&gt;mission&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Alexandra --2-- Maria --5-- Sofia --4-- Tessa --1-- Pedro
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So let's assign every relationship an introduction cost. A close relationship has a low cost because asking for an introduction is easy. A weak acquaintance has a high cost because... well, good luck with that.&lt;/p&gt;

&lt;p&gt;The BFS algorithm doesn't know how to handle weights. For weighted graphs, we need to move our attention to &lt;strong&gt;Dijkstra's algorithm&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Dijkstra's algorithm, briefly
&lt;/h4&gt;

&lt;p&gt;Dijkstra's algorithm asks a slightly different question:&lt;/p&gt;

&lt;p&gt;"What is the cheapest path from A to B?"&lt;/p&gt;

&lt;p&gt;Instead of exploring nodes in the order we discover them, we prioritize the node who currently has the lowest accumulated cost from our starting point.&lt;/p&gt;

&lt;p&gt;That usually means replacing BFS's regular queue with a priority queue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Same graph, different nouns
&lt;/h2&gt;

&lt;p&gt;The Pedro Pascal situation is ridiculous, i know, but the underlying problem isn't. Change what the nodes and edges represent, and suddenly the same ideas appear everywhere.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Domain&lt;/th&gt;
&lt;th&gt;Nodes&lt;/th&gt;
&lt;th&gt;Edges&lt;/th&gt;
&lt;th&gt;What "shortest path" answers&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Social graph&lt;/td&gt;
&lt;td&gt;People&lt;/td&gt;
&lt;td&gt;Relationships&lt;/td&gt;
&lt;td&gt;"How many introductions to Pedro Pascal?"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Maps / GPS&lt;/td&gt;
&lt;td&gt;Intersections&lt;/td&gt;
&lt;td&gt;Roads (weighted by time/distance)&lt;/td&gt;
&lt;td&gt;"Fastest route from A to B"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Web crawling&lt;/td&gt;
&lt;td&gt;Web pages&lt;/td&gt;
&lt;td&gt;Hyperlinks&lt;/td&gt;
&lt;td&gt;"How many clicks from this page to that one?"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Codebases&lt;/td&gt;
&lt;td&gt;Modules/files&lt;/td&gt;
&lt;td&gt;Imports/dependencies&lt;/td&gt;
&lt;td&gt;"What breaks if I change this file?"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recommendations&lt;/td&gt;
&lt;td&gt;Users or items&lt;/td&gt;
&lt;td&gt;Similarity/interaction strength&lt;/td&gt;
&lt;td&gt;"What's most relevant to this user?"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Graphs are one of those computer science concepts that you initially hate and mostly dont understand. Nodes. Edges. Traversals. Queues. But they are everywhere.. The internet itself is basically one very big graph.&lt;/p&gt;

&lt;p&gt;And if by any chance anyone knows someone who knows someone... You know where to find me.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>datastructures</category>
      <category>webdev</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Frontend system design interviews are weird. Here’s how I now approach functional requirements.</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Sat, 08 Aug 2026 16:40:25 +0000</pubDate>
      <link>https://dev.to/ale3oula/frontend-system-design-interviews-are-weird-heres-how-i-now-approach-functional-requirements-3ea6</link>
      <guid>https://dev.to/ale3oula/frontend-system-design-interviews-are-weird-heres-how-i-now-approach-functional-requirements-3ea6</guid>
      <description>&lt;p&gt;One of the worst types of interviews for me is the system design. It feels overwhelming, even though i studied computer science, i took all the network and operating systems and DBMS courses. I have an idea on how to explain what a distributed system is. Put me in an interview, though, and sometimes my brain just goes blank.&lt;/p&gt;

&lt;p&gt;So usually in these interviews you either get a screenshot or you're given a broad prompt like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Design a notification system.&lt;br&gt;
Design a URL shortener&lt;br&gt;
Design netflix&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;On one hand, you're thinking that these systems took entire teams years to design. On the other, your brain is already jumping to WebSockets, caching, React state, API endpoints, databases, pagination, and whether you're somehow expected to know how many servers Instagram has.&lt;/p&gt;

&lt;p&gt;Let's take a step back. Before deciding how we are going to build something, we need to know what we are building. So let me introduce you to.. functional requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are functional requirements?
&lt;/h2&gt;

&lt;p&gt;Functional requirements describe &lt;strong&gt;what a system should allow its users to do&lt;/strong&gt;. You have to clarify what the capabilities of the product is and how it should behave without knowing or specifying how these will be implemented.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Design a notification system for a web application&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is very broad, and give this prompt to 10 people and you'll get 10 different sets of requirements. So what a 'notification system' means? Are these notification real-time? Can users interact with them? Do we need to keep a history? Can users mark them as read? Do they disappear?&lt;/p&gt;

&lt;p&gt;Before drawing a single architecture box, we need to establish the scope of the problem we are talking about.&lt;/p&gt;

&lt;p&gt;A first set of functional requirements could be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users can receive notifications.&lt;/li&gt;
&lt;li&gt;Users can view their notifications.&lt;/li&gt;
&lt;li&gt;Users can mark a notification as read.&lt;/li&gt;
&lt;li&gt;Users can mark all notifications as read.&lt;/li&gt;
&lt;li&gt;Users can navigate from a notification to a details page.&lt;/li&gt;
&lt;li&gt;Users can see how many unread notifications they have.&lt;/li&gt;
&lt;li&gt;Users can receive new notifications without manually refreshing the page.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Functional vs non-functional requirements
&lt;/h2&gt;

&lt;p&gt;This distinction becomes particularly important in system design interviews.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Functional requirements describe &lt;strong&gt;what the system does&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Non-functional requirements describe &lt;strong&gt;how well the system needs to do it&lt;/strong&gt; or the constraints under which it operates.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For our notification system, these could include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Functional requirement&lt;/th&gt;
&lt;th&gt;Related non-functional concern&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Receive new notifications&lt;/td&gt;
&lt;td&gt;Updates should appear with low latency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;View notification history&lt;/td&gt;
&lt;td&gt;Large histories should load efficiently&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mark notifications as read&lt;/td&gt;
&lt;td&gt;UI updates should feel immediate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;See unread count&lt;/td&gt;
&lt;td&gt;Count should remain consistent across the application&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Open related content&lt;/td&gt;
&lt;td&gt;Navigation should be reliable and accessible&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Accessibility, performance, reliability, scalability, browser support, and latency are usually concerns that influence our architecture without defining the product feature itself. Usually all of these are non-functional requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't accept the prompt as the specification
&lt;/h2&gt;

&lt;p&gt;One of the most important things to remember in a system design interview is that the interview prompt is usually intentionally incomplete. You don't get a specification, you have to deduct it with your interviewer. The most important thing in these type of interviews is to &lt;strong&gt;ask questions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example good questions in our example could be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What kinds of notifications are we supporting?&lt;/li&gt;
&lt;li&gt;Do notifications need to arrive in real time?&lt;/li&gt;
&lt;li&gt;Do users need access to their notification history?&lt;/li&gt;
&lt;li&gt;Can notifications be deleted?&lt;/li&gt;
&lt;li&gt;Do we need read/unread state?&lt;/li&gt;
&lt;li&gt;Should notifications synchronize across multiple tabs or devices?&lt;/li&gt;
&lt;li&gt;How many notifications might a user receive?&lt;/li&gt;
&lt;li&gt;Are we designing only the web experience, or mobile too?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the interviewer tells you that notifications only need to update when the page reloads, your architecture will look very different from a system expected to deliver millions of real-time updates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make assumptions explicit
&lt;/h2&gt;

&lt;p&gt;Sometimes the interviewer won't give you every answer, and leave it up to you. So at this point inevitable you will make an assumption. Make an assumption and say it out loud.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I'll assume we're designing the web notification center, notifications should arrive while the application is open, users can mark them as read, and we're not covering email or push notifications.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That single sentence dramatically reduces the problem scope.&lt;/p&gt;

&lt;p&gt;Now instead of designing Every Notification System Known to Humanity, we're designing something concrete. This is one of the reasons functional requirements are so useful: they establish the boundaries of the system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements drive architecture
&lt;/h2&gt;

&lt;p&gt;Once we understand the requirements, technical decisions start having a reason to exist.&lt;/p&gt;

&lt;p&gt;Suppose one requirement says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Users should receive new notifications while using the application without refreshing the page.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now we have a technical problem to solve.&lt;/p&gt;

&lt;p&gt;How our system can solve this concrete problem? We could consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;polling&lt;/li&gt;
&lt;li&gt;Server-Sent Events&lt;/li&gt;
&lt;li&gt;WebSockets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, we didn't jump immediately to a conclusion to use Websockets? We derived it from a user requirement and the architecture followed.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Users can view older notifications.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now we need to think about pagination and data fetching.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Users can mark notifications as read.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now we need to think about mutations, optimistic updates, error handling, and synchronization.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Users can see their unread count throughout the application.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now we need to think about where that state lives and how different parts of the UI stay consistent.&lt;/p&gt;

&lt;h2&gt;
  
  
  From requirements to frontend architecture
&lt;/h2&gt;

&lt;p&gt;A useful way to think about the process is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Functional requirements
        ↓
User flows
        ↓
Data model
        ↓
API contracts
        ↓
Client architecture
        ↓
State management
        ↓
Rendering &amp;amp; performance
        ↓
Accessibility
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These aren't perfectly isolated steps. Real systems are messy, requirements change, and decisions influence each other. But we move from a non defined problem to an architectural decision.&lt;/p&gt;

&lt;p&gt;Going back to our notification example: the user flow "click the bell, see 5 unread, mark one, count drops to 4" already forces a data model decision about where read/unread state lives, which in turn shapes the API contract and how the client keeps that count in sync. Each arrow in the pipeline above is really a question you're answering, not just a step you're passing through.&lt;/p&gt;

&lt;h2&gt;
  
  
  Functional requirements also protect your scope
&lt;/h2&gt;

&lt;p&gt;System design prompts can become enormous very quickly.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Design Instagram.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What does that even mean? The feed? Posting photos? Stories? Profiles?&lt;/p&gt;

&lt;p&gt;It's impossible trying to design all of Instagram in a 45-minute interview, despite what all the vibe coders tell you.&lt;/p&gt;

&lt;p&gt;Perhaps we can agree with the interviewer that we are designing the home feed and narrow down the problem to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users can view posts from accounts they follow.&lt;/li&gt;
&lt;li&gt;Users can continuously load older posts.&lt;/li&gt;
&lt;li&gt;Users can like a post.&lt;/li&gt;
&lt;li&gt;Users can open a post.&lt;/li&gt;
&lt;li&gt;Users can see new content when it becomes available.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And booom...now we have something we can actually design.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with "what", then design "how"
&lt;/h2&gt;

&lt;p&gt;System design interviews aren't a competition to mention the largest number of technologies before the clock runs out. They're about making engineering decisions under incomplete information.&lt;/p&gt;

&lt;p&gt;Functional requirements give those decisions context.&lt;/p&gt;

&lt;p&gt;Suddenly, you're not designing Netflix anymore but a specific set of behaviours with specific problems to solve.&lt;/p&gt;

&lt;p&gt;And once you know what you're building, reasoning about how to build it becomes a lot less scary.&lt;/p&gt;

&lt;p&gt;At least that's what I'm trying to teach my brain before my next system design interview. 😅&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>frontend</category>
      <category>interview</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>The 10 JS Topics Every Frontend Engineer Should Know</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Wed, 05 Aug 2026 08:20:52 +0000</pubDate>
      <link>https://dev.to/ale3oula/the-10-js-topics-every-frontend-engineer-should-know-1blj</link>
      <guid>https://dev.to/ale3oula/the-10-js-topics-every-frontend-engineer-should-know-1blj</guid>
      <description>&lt;p&gt;Maybe AI is THE "hot" topic, but interviews are as old as ever. As i am studying for that said interviews, I compiled a list of 10 JS topics I think that are very crucial to prove the understanding of. These are topics I have been asked or ask during my 10 years in tech🤗.   &lt;/p&gt;

&lt;h3&gt;
  
  
  1. Execution Context &amp;amp; Hoisting
&lt;/h3&gt;

&lt;p&gt;Level: Very common. I have been asked about hoisting so much during all my years of experience. &lt;/p&gt;

&lt;p&gt;Before JS runs your code, it creates an execution context. A new context is created when a program starts or when a new function is executed. During this phase it allocates memory for variables and functions. var variables are hoisted and initialised as undefined, while let and const are hoisted but remain in the Temporal Dead Zone until their declaration.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// undefined&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&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;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Hoisting" rel="noopener noreferrer"&gt;MDN — Hoisting&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let" rel="noopener noreferrer"&gt;MDN — &lt;code&gt;let&lt;/code&gt; and the Temporal Dead Zone&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://javascript.info/closure" rel="noopener noreferrer"&gt;javascript.info — Variable scope, closure&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Closures
&lt;/h3&gt;

&lt;p&gt;Level: Common. Mostly asked to mid FE. &lt;/p&gt;

&lt;p&gt;A closure happens when a function remembers variables from the scope where it was created, even after that outer function has finished executing.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&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="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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

&lt;span class="nf"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;
&lt;span class="nf"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// 2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Classic interview example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;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="nx"&gt;result&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="c1"&gt;// 10&lt;/span&gt;
&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]();&lt;/span&gt; &lt;span class="c1"&gt;// 10&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;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="nx"&gt;result&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="c1"&gt;// 0&lt;/span&gt;
&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]();&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures" rel="noopener noreferrer"&gt;MDN — Closures&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://javascript.info/closure" rel="noopener noreferrer"&gt;javascript.info — Closure&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Video: &lt;a href="https://www.youtube.com/results?search_query=fun+fun+function+closures" rel="noopener noreferrer"&gt;Closures in JavaScript — Fun Fun Function&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. The Event Loop
&lt;/h3&gt;

&lt;p&gt;Level: Very common. Asked at every level. Usually as questions "predict the output" like the one below.&lt;/p&gt;

&lt;p&gt;JS is single threaded, meaning it runs one line of code at a time. The Event Loop decides when callbacks (macrotasks, think timers) or promises (microtasks) are allowed to run after the current code (executed in the call stack) has finished.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&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="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;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="mi"&gt;2&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="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Output:&lt;/span&gt;
&lt;span class="c1"&gt;// 1&lt;/span&gt;
&lt;span class="c1"&gt;// 4&lt;/span&gt;
&lt;span class="c1"&gt;// 3&lt;/span&gt;
&lt;span class="c1"&gt;// 2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2m4qa0gghf2aideidb65.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2m4qa0gghf2aideidb65.png" alt="The JavaScript Event Loop — call stack, Web APIs, microtask and macrotask queues" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Event_loop" rel="noopener noreferrer"&gt;MDN — Concurrency model and the event loop&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Video: &lt;a href="https://www.youtube.com/watch?v=8aGhZQkoFbQ" rel="noopener noreferrer"&gt;Philip Roberts — "What the heck is the event loop anyway?" (JSConf)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Interactive: &lt;a href="http://latentflip.com/loupe/" rel="noopener noreferrer"&gt;Loupe — visualize the event loop in real time&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Promises &amp;amp; Async/Await
&lt;/h3&gt;

&lt;p&gt;Level: Very common. Understandably, there is no way to not have async behaviour in an app in 2026.&lt;/p&gt;

&lt;p&gt;Promises represent work that will finish later. &lt;code&gt;async&lt;/code&gt; and &lt;code&gt;await&lt;/code&gt; is syntactic sugar for promises that let you write asynchronous code that looks like synchronous code.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/user&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;response&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises" rel="noopener noreferrer"&gt;MDN — Using promises&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function" rel="noopener noreferrer"&gt;MDN — &lt;code&gt;async function&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://javascript.info/async-await" rel="noopener noreferrer"&gt;javascript.info — Async/await&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. &lt;code&gt;this&lt;/code&gt; Keyword
&lt;/h3&gt;

&lt;p&gt;Level: Common. Mostly junior to mid FE.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this&lt;/code&gt; refers to the object that is calling the function. Its value&lt;br&gt;
depends on how the function is invoked.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alex&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// Alex&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this" rel="noopener noreferrer"&gt;MDN — &lt;code&gt;this&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://javascript.info/object-methods" rel="noopener noreferrer"&gt;javascript.info — Object methods, "this"&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind" rel="noopener noreferrer"&gt;MDN — &lt;code&gt;Function.prototype.bind()&lt;/code&gt;&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Objects &amp;amp; Recursion
&lt;/h3&gt;

&lt;p&gt;Level: Less common as trivia, but shows up in live coding (deep clone, tree traversal, flattening nested objects).&lt;/p&gt;

&lt;p&gt;Recursion is when a function calls itself. It's useful for traversing&lt;br&gt;
nested objects or tree-like structures.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;countDown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&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="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;countDown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Recursion" rel="noopener noreferrer"&gt;MDN — Recursion (Glossary)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://javascript.info/recursion" rel="noopener noreferrer"&gt;javascript.info — Recursion and stack&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7. Arrays &amp;amp; Data Manipulation
&lt;/h3&gt;

&lt;p&gt;Level: Very common. You need to know how to manipulate data. &lt;/p&gt;

&lt;p&gt;Frontend applications constantly read and manipulate API data. Methods like &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;filter&lt;/code&gt;, and &lt;code&gt;reduce&lt;/code&gt; make this easier.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;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="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alice&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;active&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;active&lt;/span&gt;&lt;span class="p"&gt;:&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;activeUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&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="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;active&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;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map" rel="noopener noreferrer"&gt;MDN — &lt;code&gt;Array.prototype.map()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter" rel="noopener noreferrer"&gt;MDN — &lt;code&gt;Array.prototype.filter()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce" rel="noopener noreferrer"&gt;MDN — &lt;code&gt;Array.prototype.reduce()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections" rel="noopener noreferrer"&gt;MDN — Array methods overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  8. Browser Rendering &amp;amp; Performance
&lt;/h3&gt;

&lt;p&gt;Level: Less common. Mostly senior or performance-focused roles.&lt;/p&gt;

&lt;p&gt;The browser converts HTML, CSS, and JavaScript into pixels on the&lt;br&gt;
screen. Efficient updates reduce unnecessary layout and painting work.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;transform&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;translateX(100px)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://web.dev/articles/rendering-performance" rel="noopener noreferrer"&gt;web.dev — Rendering Performance&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/Performance/Guides/How_browsers_work" rel="noopener noreferrer"&gt;MDN — Populating the page: how browsers work&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://web.dev/articles/avoid-large-complex-layouts-and-layout-thrashing" rel="noopener noreferrer"&gt;web.dev — Avoid large, complex layouts and layout thrashing&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  9. Event Propagation
&lt;/h3&gt;

&lt;p&gt;Level: Common. Mid FE and up.&lt;/p&gt;

&lt;p&gt;Events travel through the DOM. They first capture down the tree, then&lt;br&gt;
bubble back up. Event delegation uses bubbling to handle many events with one listener.&lt;/p&gt;

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

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Scripting/Event_bubbling" rel="noopener noreferrer"&gt;MDN — Event bubbling and capture&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://javascript.info/bubbling-and-capturing" rel="noopener noreferrer"&gt;javascript.info — Bubbling and capturing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://javascript.info/event-delegation" rel="noopener noreferrer"&gt;javascript.info — Event delegation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  10. Memory Management
&lt;/h3&gt;

&lt;p&gt;Level: Less common as a direct question, but senior interviews may have a "why is this leaking?" scenario.&lt;/p&gt;

&lt;p&gt;JavaScript automatically frees unused memory, but objects can stay alive if something still references them, such as an event listener or timer.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Later when no longer needed&lt;/span&gt;
&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleClick&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;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_management" rel="noopener noreferrer"&gt;MDN — Memory management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.chrome.com/docs/devtools/memory-problems/" rel="noopener noreferrer"&gt;Chrome DevTools — Fix memory problems&lt;/a&gt; &lt;em&gt;(hands-on: heap snapshots, detached DOM nodes)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://web.dev/articles/detached-window-memory-leaks" rel="noopener noreferrer"&gt;web.dev — Memory leaks in web apps&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Repaint vs Reflow: A Simple Explanation</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Mon, 03 Aug 2026 13:34:46 +0000</pubDate>
      <link>https://dev.to/ale3oula/repaint-vs-reflow-a-simple-explanation-1m4j</link>
      <guid>https://dev.to/ale3oula/repaint-vs-reflow-a-simple-explanation-1m4j</guid>
      <description>&lt;h2&gt;
  
  
  What's happening when a website loads?
&lt;/h2&gt;

&lt;p&gt;When you visit a website, your browser reads the code, it creates the DOM, it reads the CSS, it builds the CSSOM, figures out where everything should go, and then draws it on your screen. This process includes two main concepts: &lt;strong&gt;repaint&lt;/strong&gt; and &lt;strong&gt;reflow&lt;/strong&gt;. &lt;/p&gt;

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

&lt;h2&gt;
  
  
  What is a repaint?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;repaint&lt;/strong&gt; happens when you change the &lt;em&gt;appearance&lt;/em&gt; of an element, but NOT the sizes or positions. Think it as changing a text or background color, opacity, borders or box shadows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;backgroundColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;yellow&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When this happens, the browser just needs to redraw the pixels on screen. In general, this is somewhat fast.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a reflow?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;reflow&lt;/strong&gt; (or "layout") happens when you change the size or position of an element. Think about it as a result of changing width, height, padding or margins, adding or removing elements from the page, showing/hiding elements with display property, or changing the font size.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;newElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;500px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;newElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;padding&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;20px&lt;/span&gt;&lt;span class="dl"&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="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newElement&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When this happens, the browser has to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Recalculate where everything should be &lt;/li&gt;
&lt;li&gt;Figure out the new size of elements&lt;/li&gt;
&lt;li&gt;Update all the affected elements&lt;/li&gt;
&lt;li&gt;THEN repaint everything&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's why reflows are a bit expensive.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Why Should We Care?
&lt;/h2&gt;

&lt;p&gt;Both repaints and reflows make the browser do work, which can make your website feel slow, especially when you trigger them often.&lt;/p&gt;

&lt;p&gt;Imagine you're building a feature that updates a user's score:&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;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Reflow!&lt;/span&gt;
  &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                  &lt;span class="c1"&gt;// Reflow!&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every loop iteration triggers a reflow because we're changing the width and content. That's 100+ potential reflows! Modern browsers do batch some of these automatically, but you still want to minimize layout recalculations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;199px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Prefer to do all the changes at once. The browser will likely batch these into a single reflow cycle instead of triggering multiple sequential ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips to Avoid Performance Problems
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Batch your changes&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="c1"&gt;// Good&lt;/span&gt;
   &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cssText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;width: 100px; height: 100px; color: red;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="c1"&gt;// Not as good&lt;/span&gt;
   &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;100px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;100px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Avoid reading layout properties in loops&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="c1"&gt;// Bad — alternating reads and writes force recalculation&lt;/span&gt;
&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currentWidth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;offsetWidth&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// READ — forces layout recalculation&lt;/span&gt;
  &lt;span class="nx"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentWidth&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// WRITE — invalidates layout&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Good — batch all reads first, then writes&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;widths&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="nx"&gt;elements&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="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;offsetWidth&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;widths&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Use classes instead of inline styles&lt;/strong&gt; (similar with 1)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="c1"&gt;// Good — batches all CSS changes together and is more maintainable&lt;/span&gt;
&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;highlighted&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Not as good — multiple individual property assignments can trigger separate reflows&lt;/span&gt;
&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;blue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;backgroundColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;yellow&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fontWeight&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bold&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS classes batch multiple properties into a single reflow cycle, and keep your styling logic separate from your JavaScript.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Use transforms for animations&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="c1"&gt;// Good for animations&lt;/span&gt;
   &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;transform&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;translateX(100px)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="c1"&gt;// Causes reflow&lt;/span&gt;
   &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;100px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Transforms are cheaper because they skip the Layout and Paint phases of the rendering pipeline and only trigger Composite (which happens on the GPU). Position changes like left, top, width, and height require the browser to recalculate the entire layout.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Use requestAnimationFrame for Coordinated Updates&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When you need to perform multiple DOM reads and writes in animations, use &lt;code&gt;requestAnimationFrame&lt;/code&gt; to ensure they're batched together in the browser's rendering cycle:&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;// Good — batches all changes into one frame&lt;/span&gt;
&lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;transform&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;translateX(100px)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Less efficient — each update happens immediately, may cause multiple recalculations&lt;/span&gt;
&lt;span class="nx"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;transform&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;translateX(100px)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Modern Browser Considerations
&lt;/h3&gt;

&lt;p&gt;Browsers have become smarter about batching DOM operations. Modern engines like V8 (Chrome) and SpiderMonkey (Firefox) automatically defer and batch layout recalculations to some degree. However, this doesn't mean poor practices are harmless, you can still force synchronous reflows by reading layout properties like offsetWidth, clientHeight, or getBoundingClientRect() immediately after writing styles. Avoiding these patterns ensures your code stays performant across all browsers and circumstances.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Bottom Line
&lt;/h2&gt;

&lt;p&gt;☑️ &lt;strong&gt;Repaint&lt;/strong&gt; = Change colors/appearance → relatively fast&lt;br&gt;
☑️ &lt;strong&gt;Reflow&lt;/strong&gt; = Change size/position/layout → slower, more expensive&lt;br&gt;
☑️ Both slow down your site if you do too many&lt;br&gt;
☑️ Group changes together when possible&lt;br&gt;
☑️ Use CSS transforms for animations&lt;/p&gt;

&lt;p&gt;Next time a website feels slow, there's a good chance it's because the browser is constantly doing reflows and repaints.&lt;/p&gt;

&lt;h3&gt;
  
  
  Further Reading
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Visual_formatting_model" rel="noopener noreferrer"&gt;MDN: Visual formatting model&lt;/a&gt; - Background on how browsers lay out pages&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://web.dev/articles/avoid-large-complex-layouts-and-layout-thrashing" rel="noopener noreferrer"&gt;web.dev: Avoid large, complex layouts and layout thrashing&lt;/a&gt; - Google's deep dive specifically on layout thrashing and how to avoid it&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://web.dev/articles/rendering-performance" rel="noopener noreferrer"&gt;web.dev: Rendering Performance&lt;/a&gt; - The full pixel pipeline (JS → Style → Layout → Paint → Composite)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://csstriggers.com/" rel="noopener noreferrer"&gt;CSS Triggers&lt;/a&gt; - A reference showing exactly which CSS properties trigger layout, paint, or composite&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.chrome.com/docs/devtools/performance/" rel="noopener noreferrer"&gt;Chrome DevTools: Analyze runtime performance&lt;/a&gt; - How to actually profile and see reflows/repaints happening in your own site&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>css</category>
      <category>frontend</category>
      <category>performance</category>
      <category>webdev</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Mon, 03 Aug 2026 11:48:39 +0000</pubDate>
      <link>https://dev.to/ale3oula/-40fn</link>
      <guid>https://dev.to/ale3oula/-40fn</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/ale3oula/does-the-web-feel-slower-these-days-9pi" class="crayons-story__hidden-navigation-link"&gt;Does the web feel slower these days?&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/ale3oula" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F155897%2Fbd0b9c2b-1685-487f-9de3-5096a19ae2eb.png" alt="ale3oula profile" class="crayons-avatar__image" width="100" height="100"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/ale3oula" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Alexandra
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Alexandra
                
              
              &lt;div id="story-author-preview-content-4181150" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/ale3oula" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F155897%2Fbd0b9c2b-1685-487f-9de3-5096a19ae2eb.png" class="crayons-avatar__image" alt="" width="100" height="100"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Alexandra&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/ale3oula/does-the-web-feel-slower-these-days-9pi" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jul 20&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/ale3oula/does-the-web-feel-slower-these-days-9pi" id="article-link-4181150"&gt;
          Does the web feel slower these days?
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/ale3oula/does-the-web-feel-slower-these-days-9pi" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;4&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/ale3oula/does-the-web-feel-slower-these-days-9pi#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            4 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>The Comfort Atlas: What Does Home Taste Like?</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Sat, 01 Aug 2026 21:19:16 +0000</pubDate>
      <link>https://dev.to/ale3oula/the-comfort-atlas-what-does-home-taste-like-3a6i</link>
      <guid>https://dev.to/ale3oula/the-comfort-atlas-what-does-home-taste-like-3a6i</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/challenges/frontend-2026-07-29"&gt;Frontend Challenge - Comfort Food Edition, Perfect Landing&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;The Comfort Atlas is a spinning 3D globe of comfort food from ~100 countries. &lt;/p&gt;

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

&lt;p&gt;Virtually travel the globe and have a taste of the comfort foods from 100~ countries. Moussaka in Greece, Jollof Rice in Nigeria, Pho in Vietnam. There is also a "featured dish of the day" that rotates deterministically so it's the same for everyone visiting that day. And the fun feature: visitors can type in their own comfort dish and generate a downloadable, passport-stamp-style card in one of three color styles.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://comfort-atlas.netlify.app/" rel="noopener noreferrer"&gt;https://comfort-atlas.netlify.app/&lt;/a&gt;&lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag-netlify"&gt;
  &lt;iframe src="https://comfort-atlas.netlify.app/" title="Netlify embed"&gt;
  &lt;/iframe&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Journey
&lt;/h2&gt;

&lt;p&gt;I started with a flat SVG world map, clickable countries, keyboard support, a hover tooltip on the map, all built on real  elements so accessibility came for free. It worked fine, but it looked very meh.&lt;/p&gt;

&lt;p&gt;So i decided to try something i have never done before. Make a globe! I used &lt;code&gt;cobe&lt;/code&gt; which promised a 3D globe out of the box. First attempt rendered absolutely nothing but floating dots. 😂  With a lot of the help of my friend claude, we found out that their docs are outdated, and there is a &lt;code&gt;createGlobe()&lt;/code&gt; that draws exactly one synchronous frame and expects you to drive a requestAnimationFrame loop calling .update() yourself.&lt;/p&gt;

&lt;p&gt;Two things on the globe I'm  proud of, because neither had any library support: a hover tooltip that tracks a marker in 3D space, and a fading "trail" of great-circle arcs between the countries you've visited. Both came down to translating the projection math out of a minified bundle into something readable.&lt;/p&gt;

&lt;p&gt;What I would do next: dark mode, enrich the content, comfort food battles per country.&lt;/p&gt;

&lt;p&gt;What I learned: a lot about accessibility in 3D/canvas, which is so much more difficult than the 2d one, one check for a11y is never enough. Maps are hard, and getting something to track a moving 3D object from regular DOM is even harder.&lt;/p&gt;

&lt;p&gt;Licensed under MIT&lt;/p&gt;

&lt;p&gt;Fun fact: I don't like Moussaka, even though i am greek, my comfort food is Pizza or Giouvetsi. xD &lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>frontendchallenge</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Collaborative Filtering: How Computers Find Your Next Favourite Thing</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Fri, 31 Jul 2026 18:01:28 +0000</pubDate>
      <link>https://dev.to/ale3oula/collaborative-filtering-how-computers-find-your-next-favourite-thing-22em</link>
      <guid>https://dev.to/ale3oula/collaborative-filtering-how-computers-find-your-next-favourite-thing-22em</guid>
      <description>&lt;h1&gt;
  
  
  🎯 Finding Your Taste Twin
&lt;/h1&gt;

&lt;p&gt;Imagine walking into a party where you don't know anyone.&lt;/p&gt;

&lt;p&gt;Someone notices your t-shirt and starts a conversation: "You like Arctic Monkeys? Me too."&lt;/p&gt;

&lt;p&gt;"You also watched Severance?"&lt;br&gt;
And your favorite game is Baldur's Gate 3?"&lt;/p&gt;

&lt;p&gt;After five minutes, you realize you share almost identical tastes.&lt;/p&gt;

&lt;p&gt;Then they say: "You HAVE to watch Silo."&lt;/p&gt;

&lt;p&gt;Chances are you'll trust them. Not because you know anything about Silo. But because this stranger has repeatedly proven they like the same things you do.&lt;/p&gt;

&lt;p&gt;That my friends, is collaborative filtering.&lt;/p&gt;

&lt;h1&gt;
  
  
  ⚙️ The Mystery: How Does Netflix Know?
&lt;/h1&gt;

&lt;p&gt;It's tempting to think Netflix stores detailed notes on every film ever made. Somehow the algorithm always recommends something you end up liking. Maybe it relates actors? or genres?or cinematography?&lt;/p&gt;

&lt;p&gt;While some recommendation systems definitely can use that information, collaborative filtering doesn't need any of it. Instead, to the algorithm every movie is just a column in a giant spreadsheet and it asks a much simpler question: &lt;strong&gt;Who else behaves like you?&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;User&lt;/th&gt;
&lt;th&gt;Iron Man&lt;/th&gt;
&lt;th&gt;Barbie&lt;/th&gt;
&lt;th&gt;Titanic&lt;/th&gt;
&lt;th&gt;Matrix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Alice&lt;/td&gt;
&lt;td&gt;⭐⭐⭐⭐⭐&lt;/td&gt;
&lt;td&gt;⭐&lt;/td&gt;
&lt;td&gt;⭐&lt;/td&gt;
&lt;td&gt;⭐⭐⭐⭐⭐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bob&lt;/td&gt;
&lt;td&gt;⭐⭐⭐⭐&lt;/td&gt;
&lt;td&gt;⭐&lt;/td&gt;
&lt;td&gt;⭐&lt;/td&gt;
&lt;td&gt;⭐⭐⭐⭐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Carol&lt;/td&gt;
&lt;td&gt;⭐&lt;/td&gt;
&lt;td&gt;⭐⭐⭐⭐⭐&lt;/td&gt;
&lt;td&gt;⭐⭐⭐⭐&lt;/td&gt;
&lt;td&gt;⭐&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h1&gt;
  
  
  A Quick History
&lt;/h1&gt;

&lt;p&gt;Collaborative filtering dates back to the early 1990s. Researchers working on a project called &lt;strong&gt;GroupLens&lt;/strong&gt; realised something:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;People who agreed in the past often agree again in the future.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Amazon, Netflix, and Spotify later applied similar ideas to recommendations. Today, almost every major platform uses collaborative filtering as part of a larger system.&lt;/p&gt;

&lt;h1&gt;
  
  
  How the Algorithm Finds Your Taste Twin
&lt;/h1&gt;

&lt;p&gt;Collaborative filtering doesn't understand products. It doesn't know anything about movies or music. It's based on the idea that people with similar past behavior often make similar choices.&lt;/p&gt;

&lt;p&gt;You and another person watched these movies:&lt;/p&gt;

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

&lt;p&gt;The recommendation engine gives a high similarity score between you and Kelly because your ratings are consistently alike.&lt;/p&gt;

&lt;p&gt;If Kelly watches &lt;strong&gt;Dune&lt;/strong&gt; and rates it with 5 stars, there's a good chance you will love Dune too.&lt;/p&gt;

&lt;p&gt;Under the hood, these systems often compare users using mathematical similarity measures like cosine similarity or Pearson correlation. You don't need to understand the formulas to understand the idea: the system compares the users history with millions of other users. The more often two people agree, the more similar they become.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measuring Similarity
&lt;/h2&gt;

&lt;p&gt;So far, we've treated "similarity" as a vague concept, but recommendation systems need a number.&lt;/p&gt;

&lt;p&gt;There are several ways to calculate how similar two users are:&lt;/p&gt;

&lt;h3&gt;
  
  
  Cosine Similarity
&lt;/h3&gt;

&lt;p&gt;Imagine each user's ratings are represented as a vector.&lt;/p&gt;

&lt;p&gt;You: [5, 4, 1, 5]&lt;br&gt;
Kelly: [5, 4, 1, 4]&lt;/p&gt;

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

&lt;p&gt;Cosine similarity measures the angle between those vectors.&lt;/p&gt;

&lt;p&gt;A score close to &lt;strong&gt;1&lt;/strong&gt; means the users have very similar preferences.&lt;br&gt;
A score close to &lt;strong&gt;0&lt;/strong&gt; means they're largely unrelated.&lt;/p&gt;

&lt;p&gt;The actual formula looks intimidating:&lt;/p&gt;

&lt;p&gt;cos(θ) = (A · B) / (||A|| ||B||)&lt;/p&gt;

&lt;p&gt;Fortunately, the intuition is much simpler than the equation:&lt;/p&gt;

&lt;p&gt;users whose rating vectors point in roughly the same direction tend to enjoy the same things.&lt;/p&gt;

&lt;h1&gt;
  
  
  A different approach
&lt;/h1&gt;

&lt;p&gt;Everything we've seen so far is called &lt;code&gt;User-Based Collaborative Filtering&lt;/code&gt;. Another approach is &lt;code&gt;Item-Based Collaborative Filtering&lt;/code&gt;. In our previous movie example, imagine targeting similar movies instead of users. If thousands of viewers liked Interstellar AND Arrival AND Blade Runner, there is a good chance they will love Dune too.&lt;/p&gt;

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

&lt;p&gt;This algorithm groups movies that frequently appear together, so when you watch 2-3 k-dramas, now your feed is full of them. Not because the system understands the genre, but because lots of people who loved the choice A loved the choice B too.&lt;/p&gt;

&lt;h1&gt;
  
  
  You Don't Even Need Ratings
&lt;/h1&gt;

&lt;p&gt;I don't know who even remembers this, but in the early days of Netflix you could rate movies with stars. You don't actually need them. Modern recommendation systems often learn from your behaviour. Instead of asking if you like something or you, they watch things like "did she finish the movie?", "what did you rewatch", "what do you have in your wishlist", "what you stop after two minutes".&lt;/p&gt;

&lt;p&gt;This is called implicit feedback, and it is often more reliable than ratings because it reflects what people actually do.&lt;/p&gt;

&lt;h1&gt;
  
  
  Where It Breaks Down
&lt;/h1&gt;

&lt;p&gt;Collaborative filtering is powerful but it has some problems:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The New User Problem
&lt;/h2&gt;

&lt;p&gt;If you are a new user in Netflix, you haven't watched anything. So nobody is at this point similar to you. This is called the &lt;strong&gt;Cold Start Problem&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Solution: Ask new users to rate a few movies first, or show them the most popular content until you have enough data.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The New Movie Problem
&lt;/h2&gt;

&lt;p&gt;A new movie released today, but this means that nobody has watched it yet, and thus nobody has rated it. So the collaborative filtering cannot recommend it.&lt;/p&gt;

&lt;p&gt;Solution: Use content-based filtering (analyzing genre, cast, plot) until the movie has enough ratings.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Taste Changes
&lt;/h2&gt;

&lt;p&gt;A very human behaviour we have is that our taste changes over time. Maybe in 2018 you mostly watched cheesy hallmark movies and then in 2026 you watch only animes. The problem is that your old ratings still exist.&lt;/p&gt;

&lt;p&gt;Solution: Recommendation systems weight recent behaviour more heavily than old behaviour, so your old tastes and choices doesn't haunt you forever.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Niche Content
&lt;/h2&gt;

&lt;p&gt;The thing with recommendation systems is that they need data. A lot of them. So popular movies which have millions of ratings are more likely to get endorsed.&lt;/p&gt;

&lt;p&gt;Independent films might have only a few hundred, which makes niche content harder to recommend. The algorithm works best with volume. Blockbusters get pushed. Hidden gems stay hidden.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. The Filter Bubble
&lt;/h2&gt;

&lt;p&gt;Recommendation systems can accidentally reinforce your existing preferences. If Netflix keeps recommending crime dramas, you're more likely to watch them. The system then becomes even more confident that crime dramas are what you like, creating a feedback loop. Over time this can reduce diversity in recommendations and make it harder to discover completely new kinds of content.&lt;/p&gt;

&lt;h1&gt;
  
  
  Key Takeaways
&lt;/h1&gt;

&lt;p&gt;✅ Collaborative filtering doesn't need to understand movies or products but instead looks for people with similar behaviour.&lt;br&gt;
✅ Similar people often make similar future choices.&lt;br&gt;
✅ More data usually means better recommendations. The algorithm gets smarter as more people use it.&lt;br&gt;
✅ Modern recommendation systems combine collaborative filtering with many other techniques. Content-based filtering, deep learning, and hybrid approaches all work together to overcome individual weaknesses.&lt;/p&gt;

&lt;h1&gt;
  
  
  Resources
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Google Developers — Recommendation Systems&lt;br&gt;
&lt;a href="https://developers.google.com/machine-learning/recommendation" rel="noopener noreferrer"&gt;https://developers.google.com/machine-learning/recommendation&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Google Developers — Collaborative Filtering&lt;br&gt;
&lt;a href="https://developers.google.com/machine-learning/recommendation/collaborative/basics" rel="noopener noreferrer"&gt;https://developers.google.com/machine-learning/recommendation/collaborative/basics&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Using Collaborative Filtering to Weave an Information Tapestry&lt;/strong&gt; - Goldberg, Nichols, Oki &amp;amp; Terry (1992)&lt;br&gt;
&lt;a href="https://dl.acm.org/doi/10.1145/138859.138867" rel="noopener noreferrer"&gt;https://dl.acm.org/doi/10.1145/138859.138867&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;GroupLens: An Open Architecture for Collaborative Filtering of Netnews&lt;/strong&gt; - Resnick et al. (1994)&lt;br&gt;
&lt;a href="https://dl.acm.org/doi/10.1145/192844.192905" rel="noopener noreferrer"&gt;https://dl.acm.org/doi/10.1145/192844.192905&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Item-Based Collaborative Filtering Recommendation Algorithms&lt;/strong&gt; - Sarwar et al. (2001)&lt;br&gt;
&lt;a href="https://dl.acm.org/doi/10.1145/371920.372071" rel="noopener noreferrer"&gt;https://dl.acm.org/doi/10.1145/371920.372071&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Recommender Systems: The Textbook&lt;/strong&gt; - Charu C. Aggarwal&lt;br&gt;
&lt;a href="https://link.springer.com/book/10.1007/978-3-319-29659-3" rel="noopener noreferrer"&gt;https://link.springer.com/book/10.1007/978-3-319-29659-3&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>algorithms</category>
      <category>ai</category>
      <category>machinelearning</category>
      <category>recommendations</category>
    </item>
    <item>
      <title>Understanding JavaScript Execution Context: The Foundation of Interactivity</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Mon, 27 Jul 2026 10:47:33 +0000</pubDate>
      <link>https://dev.to/ale3oula/understanding-javascript-execution-context-the-foundation-of-interactivity-2dah</link>
      <guid>https://dev.to/ale3oula/understanding-javascript-execution-context-the-foundation-of-interactivity-2dah</guid>
      <description>&lt;p&gt;The most difficult thing in JavaScript is understanding how things are collaborating in order to provide interactivity. &lt;/p&gt;

&lt;p&gt;The execution context is equivalent to a workspace. Whenever JS runs some code, it creates a workspace to contain everything it needs to do it successfully. That workspace has the variables, the functions, the &lt;code&gt;this&lt;/code&gt; and information on where to continue working.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating contexts
&lt;/h3&gt;

&lt;p&gt;There are two ways to create this workspace:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When a program starts (Global execution context)&lt;/li&gt;
&lt;li&gt;Every time a function is called (Function execution context)
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alex&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;when this program starts JS creates the global context with the &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;greet&lt;/code&gt;.Then the &lt;code&gt;greet&lt;/code&gt; function is called, which creates a new execution context that includes the variable &lt;code&gt;message&lt;/code&gt;. When the function &lt;code&gt;greet()&lt;/code&gt; finishes its execution, this context is removed. When the program finishes the global context is also removed. A fair question here is: "removed from where"? The answer is: from the infamous &lt;code&gt;call stack&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The call stack
&lt;/h3&gt;

&lt;p&gt;These execution workspaces are stored in a stack. If you don't know what a stack is: it is a data structure with some specific properties. New elements are added at the top of the stack, elements are removed also from the top of the stack. The most famous comparison is to think of a stack as a stack of plate. You wouldn't remove a plate from the bottom of the stack. This property is called LIFO: Last in First out.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────┐
│   greet()   │  ← Top (will be removed first)
├─────────────┤
│   Global    │  ← Bottom (removed last)
└─────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When &lt;code&gt;greet()&lt;/code&gt; finishes, it's "pop'ed" from the stack and only the global context remains (until the end of this program)&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;first&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;second&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;second&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;third&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;third&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before any call:        During execution:       After all finish:
┌──────────────┐        ┌──────────────┐       ┌──────────────┐
│   Global     │        │   third()    │       │   Global     │
└──────────────┘        ├──────────────┤       └──────────────┘
                        │  second()    │
                        ├──────────────┤
                        │   first()    │
                        ├──────────────┤
                        │   Global     │
                        └──────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As every functions finishes their executions, it's get popped from the stack. First the &lt;code&gt;third&lt;/code&gt; finishes and it is removed, then the second, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  The two phases of the context
&lt;/h3&gt;

&lt;p&gt;Every execution context has two phases. The 1st phase is the &lt;code&gt;Creation&lt;/code&gt;: JS scans the code and prepares the memory, it identifies variables and functions. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables declared with &lt;code&gt;var&lt;/code&gt; are initialised with undefined.&lt;/li&gt;
&lt;li&gt;Functions defined with the &lt;code&gt;function&lt;/code&gt; keyword are saved as a whole. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; variables are registered in an other place called Temporal Dead Zone.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The next phase is the &lt;code&gt;execution&lt;/code&gt;: JS runs the code line-by-line. It assign values to variables and executes statements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why hoisting happens?
&lt;/h2&gt;

&lt;p&gt;There is a word that scares every web developer: &lt;strong&gt;hoisting&lt;/strong&gt;. This happens due to the creation phase. As JS scans the code it already knows about variables and functions before execution even begins. That process is called hoisting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Prints undefined, because JS initialized the a with undefined in the creation phase&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Function declarations are fully hoisted, so you can call them even before they are written.&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;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// This works! Prints "Hello"&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: function expressions are NOT hoisted. Function expressions are functions that are stored in a variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; against hoisting
&lt;/h2&gt;

&lt;p&gt;In ES6 the keywords &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; were introduced. When you run the same code as before but using &lt;code&gt;let&lt;/code&gt; this time..you get a reference error. what is happening?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// throws ReferenceError&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Javascript still knows that &lt;code&gt;a&lt;/code&gt; exists, but the difference is that now is not saved in the context. Instead, it's stored in an another place called &lt;strong&gt;Temporal dead zone (TDZ)&lt;/strong&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding TDZ
&lt;/h3&gt;

&lt;p&gt;The TDZ is a region in a block where a variable exists but cannot accessed (yet). TDZ starts from the beginning of the block until the variable is declared and initialized.&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// TDZ for 'a' starts here&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ReferenceError - 'a' is in TDZ, not accessible&lt;/span&gt;

    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;      &lt;span class="c1"&gt;// TDZ ends here, 'a' is now initialized and accessible&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 5 - now it works&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Scope Chain: Looking Beyond the Current Context
&lt;/h3&gt;

&lt;p&gt;When you reference a variable inside a function, JS doesnt only look in the current execution context. If the variable is not found in the current, it start looking on the parent, and then it's parent until it reaches the global context. This is called scope chain.&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="nb"&gt;global&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I'm a global var&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;outer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;outerVar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I'm in outer scope&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;inner&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;innerVar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I'm in inner scope&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;innerVar&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// ✅ Found in inner's context&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;outerVar&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// ✅ Found in outer's context (via scope chain)&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;    &lt;span class="c1"&gt;// ✅ Found in global context (via scope chain)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nf"&gt;inner&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;outer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  summary
&lt;/h3&gt;

&lt;p&gt;✅ JS creates an execution context before running code&lt;br&gt;
✅ Every function call creates an execution context&lt;br&gt;
✅ These contexts are managed using the call stack&lt;br&gt;
✅ Each execution context has a creation and an execution phase. &lt;br&gt;
✅ Hoisting happens in the creation phase due to the scan of the code. &lt;br&gt;
✅ &lt;code&gt;const&lt;/code&gt; and &lt;code&gt;let&lt;/code&gt; solved the initialization issues in JS by storing variables in TDZ&lt;br&gt;
✅ The scope chain allows functions to access variables from their parent contexts (lexical scoping)&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
    <item>
      <title>What Are Embeddings?: How AI Knows a Cat and a Kitten Are Related ⭐</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Sat, 25 Jul 2026 11:02:11 +0000</pubDate>
      <link>https://dev.to/ale3oula/what-are-embeddings-how-ai-knows-a-cat-and-a-kitten-are-related-232c</link>
      <guid>https://dev.to/ale3oula/what-are-embeddings-how-ai-knows-a-cat-and-a-kitten-are-related-232c</guid>
      <description>&lt;p&gt;This is a very simplified version of what an embedding is and is meant for beginners. Felt that I had to put a disclaimer here for the ai bros. &lt;/p&gt;

&lt;h2&gt;
  
  
  The question &lt;code&gt;embeddings&lt;/code&gt; answer
&lt;/h2&gt;

&lt;p&gt;How does a computer "know" that a cat and a kitten are related, that a dog is closer to a cat than to a car, and that a car is closer to a truck than to either a cat or a dog?? Computers don't understand meaning, they only understand numbers. So the trick is turning the meaning of text into numbers that math can work with.&lt;/p&gt;

&lt;p&gt;An embedding is simply a long list of numbers that represents the meaning of a piece of text. Modern embeddings often contain hundreds or even thousands of numbers, but you don't need to understand each number individually. Pieces of text with similar meaning end up close together in this mathematical space.&lt;/p&gt;

&lt;h2&gt;
  
  
  A map of meaning
&lt;/h2&gt;

&lt;p&gt;Imagine every word or phrase being placed on a giant map. Similar meanings end up close together, while unrelated end up far away. A model places words near each other based on how they are used in huge amounts of text, so "cat" and "kitten" end up near each other, "dog" and "puppy" are also close together and nearby to cats too, and something unrelated like a "car" sits in a completely different region.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkpcmh59d01sppdv0fa8p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkpcmh59d01sppdv0fa8p.png" alt="words in the 2d space" width="799" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In reality, embeddings live in far more bigger structure than a map, meaning in multiple dimensions, usually hundreds or thousands, which is impossible to actually draw (or even understand with my small 3d brain). But the two-dimensional version captures the core idea: distance yields relationships. &lt;/p&gt;

&lt;h2&gt;
  
  
  Where the numbers actually come from
&lt;/h2&gt;

&lt;p&gt;An embedding isn't assigned by a person deciding "cat should be at this coordinate". During the training phase a model gradually learns how to convert text into embeddings based on the contexts it sees across enormous amounts of data. Words used in similar contexts end up near each other, because that's all the model ever sees: patterns in language.&lt;/p&gt;

&lt;p&gt;This is also why embeddings capture relationships that go beyond simple synonyms. Classic examples show that the relationship between "king" and "queen" is mathematically similar to the relationship between "man" and "woman".&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this matters for search and recommendations
&lt;/h2&gt;

&lt;p&gt;Traditional keyword search matches exact words. Searching for an "affordable laptop" in a keyword-based system might miss a product like a "budget-friendly notebook" because the words don't literally match, even we (the humans) know that the meaning is identical.&lt;/p&gt;

&lt;p&gt;Embedding-based search fixes this problem. Instead of matching words, it converts your search query into a point in the giant map and finds the nearest neighbors/points. This is why modern search and recommendation systems can surface something relevant even when you didn't use the "right" word.&lt;/p&gt;

&lt;h2&gt;
  
  
  Words aren't the only thing that can be embedded
&lt;/h2&gt;

&lt;p&gt;Despite using words like "cat" as examples, embeddings aren't limited to single words. Entire sentences, paragraphs, documents, images, and even audio can all be represented as embeddings. The idea stays exactly the same: similar meaning ends up close together in the giant map.&lt;/p&gt;

&lt;p&gt;In previous articles we talk about RAG and how this has a retrieval step. A simplified description of the retrieval step by adding the embeddings to the calculation will be: Your question is converted into an embedding, the documents have been embedded already, and the system simply retrieves the ones that are closest in that embedding map.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this shows up if you're building products
&lt;/h2&gt;

&lt;p&gt;If you're building search, recommendations, finding duplicate content, or anything that needs to group or match content by meaning rather than exact text, embeddings are usually the tool for it, not string matching anymore.&lt;/p&gt;

&lt;p&gt;A few practical things worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Documents are usually embedded once and stored. When a user searches, only the new query needs to be embedded, making retrieval much faster.&lt;/li&gt;
&lt;li&gt;Similarity isn't the same as correctness. Two pieces of text can be very similar while still answering the wrong question. That's why many systems rank, filter, or validate results after the similarity search.&lt;/li&gt;
&lt;li&gt;The embedding model matters. Different embedding models place things differently, and a model tuned for one domain may not embed specialised or technical content as usefully as one tuned for that domain.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;If you'd like to dive deeper into embeddings and how they're used in modern AI systems, these are excellent starting points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Anthropic – Embeddings Documentation&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://platform.claude.com/docs/en/build-with-claude/embeddings" rel="noopener noreferrer"&gt;https://platform.claude.com/docs/en/build-with-claude/embeddings&lt;/a&gt;&lt;br&gt;&lt;br&gt;
A practical guide explaining what embeddings are, how they work, and how they're used for semantic search, recommendations, and retrieval. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;OpenAI – Embeddings Guide &amp;amp; FAQ&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://help.openai.com/en/articles/6824809-embeddings-faq" rel="noopener noreferrer"&gt;https://help.openai.com/en/articles/6824809-embeddings-faq&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Covers OpenAI's embedding models, common questions, distance metrics, and best practices. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Word2Vec: Efficient Estimation of Word Representations in Vector Space (2013)&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://arxiv.org/abs/1301.3781" rel="noopener noreferrer"&gt;https://arxiv.org/abs/1301.3781&lt;/a&gt;&lt;br&gt;&lt;br&gt;
The classic paper by Tomas Mikolov and colleagues that popularised learned word embeddings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pinecone – Dense Vector Embeddings Explained&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://www.pinecone.io/learn/series/nlp/dense-vector-embeddings-nlp/" rel="noopener noreferrer"&gt;https://www.pinecone.io/learn/series/nlp/dense-vector-embeddings-nlp/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
A visual, beginner-friendly explanation of dense vectors, embeddings, and semantic search, with examples beyond Word2Vec. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Jay Alammar – The Illustrated Word2vec&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://jalammar.github.io/illustrated-word2vec/" rel="noopener noreferrer"&gt;https://jalammar.github.io/illustrated-word2vec/&lt;/a&gt;&lt;br&gt;
A visual, intuitive explainer on word embeddings, in the same style as his famous "Illustrated Transformer."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Embeddings &amp;amp; Vector Search in 2026: The Engineer's Complete Guide&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://jobsbyculture.com/blog/embeddings-vector-search-guide-2026" rel="noopener noreferrer"&gt;https://jobsbyculture.com/blog/embeddings-vector-search-guide-2026&lt;/a&gt;&lt;br&gt;
Covers embedding models, ANN algorithms (HNSW, IVF), and building production RAG pipelines.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;How to Generate Better Embeddings for Vector Search&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://pr-peri.github.io/llm/2026/02/12/generate-embeddings-vector-search.html" rel="noopener noreferrer"&gt;https://pr-peri.github.io/llm/2026/02/12/generate-embeddings-vector-search.html&lt;/a&gt;&lt;br&gt;
Practical guide to improving retrieval quality via chunking, cleaning, metadata, hybrid search, and proper evaluation (Recall@K, MRR).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Best Embedding Models 2026: Tested on 50K Documents&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://pecollective.com/tools/best-embedding-models/" rel="noopener noreferrer"&gt;https://pecollective.com/tools/best-embedding-models/&lt;/a&gt;&lt;br&gt;
Compares OpenAI, Cohere, Voyage AI, and Jina embedding models on real retrieval benchmarks, not just MTEB scores.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>eli5</category>
      <category>ai</category>
      <category>beginners</category>
      <category>basic</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Fri, 24 Jul 2026 15:04:00 +0000</pubDate>
      <link>https://dev.to/ale3oula/-53a4</link>
      <guid>https://dev.to/ale3oula/-53a4</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/ale3oula/tokens-arent-words-what-actually-happens-when-you-send-a-prompt-4baj" class="crayons-story__hidden-navigation-link"&gt;Tokens aren't words: what actually happens when you send a prompt&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/ale3oula" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F155897%2Fbd0b9c2b-1685-487f-9de3-5096a19ae2eb.png" alt="ale3oula profile" class="crayons-avatar__image" width="100" height="100"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/ale3oula" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Alexandra
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Alexandra
                
              
              &lt;div id="story-author-preview-content-4180584" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/ale3oula" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F155897%2Fbd0b9c2b-1685-487f-9de3-5096a19ae2eb.png" class="crayons-avatar__image" alt="" width="100" height="100"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Alexandra&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/ale3oula/tokens-arent-words-what-actually-happens-when-you-send-a-prompt-4baj" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jul 19&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/ale3oula/tokens-arent-words-what-actually-happens-when-you-send-a-prompt-4baj" id="article-link-4180584"&gt;
          Tokens aren't words: what actually happens when you send a prompt
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/eli5"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;eli5&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/webdev"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;webdev&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/beginners"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;beginners&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/ale3oula/tokens-arent-words-what-actually-happens-when-you-send-a-prompt-4baj" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/multi-unicorn-b44d6f8c23cdd00964192bedc38af3e82463978aa611b4365bd33a0f1f4f3e97.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;5&lt;span class="hidden s:inline"&gt;&amp;nbsp;reactions&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/ale3oula/tokens-arent-words-what-actually-happens-when-you-send-a-prompt-4baj#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Stop Hiring a Rocket Scientist to Check If a Box Is Empty</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Thu, 23 Jul 2026 17:26:44 +0000</pubDate>
      <link>https://dev.to/ale3oula/stop-hiring-a-rocket-scientist-to-check-if-a-box-is-empty-1i4c</link>
      <guid>https://dev.to/ale3oula/stop-hiring-a-rocket-scientist-to-check-if-a-box-is-empty-1i4c</guid>
      <description>&lt;p&gt;One thing I've been thinking about lately is what trade-offs companies are willing to make in order to market their products as "AI-powered."&lt;/p&gt;

&lt;h2&gt;
  
  
  A tale as old as 2023
&lt;/h2&gt;

&lt;p&gt;A team needs to validate an email address. Someone asks, "What if we used AI?" Five minutes later there's a model call, an API key, a loading spinner, a monthly bill &amp;amp; somehow Kubernetes got involved. Congratulations, you've successfully turned O(1) into "please wait while we contact the cloud."&lt;/p&gt;

&lt;p&gt;This is not an argument against AI. Large language models are highly effective for many categories of problems. The issue is not the technology itself, but its application to tasks that never needed it in the first place, because it's new and shiny and everyone is doing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The actual differences
&lt;/h2&gt;

&lt;p&gt;Here's an unglamorous truth: an if statement &amp;amp; an LLM call are not doing the same job. They're built for different kinds of problems, and their differences are greater than people give it credit for.&lt;/p&gt;

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

&lt;p&gt;An if statement runs in a millisecond, costs nothing per call, and gives you the exact same answer every single time for the same input (deterministic). An LLM call, takes real time, costs real money, and can give you a slightly different answer to the exact same question depending on the day, the model version, or the wind direction.&lt;/p&gt;

&lt;h2&gt;
  
  
  if-statement or AI?
&lt;/h2&gt;

&lt;p&gt;Reach for an if statement (or a regex, or .. or ..) when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The rule is simple and well-defined. "Is this a valid email format?" "Is the cart total over $50?" "Is the field empty?"&lt;/li&gt;
&lt;li&gt;You need the same input to produce the same output. Billing logic, permission checks, form validation. No your users don't want their invoice total to vary by mood.&lt;/li&gt;
&lt;li&gt;Performance is important and there is no ambiguity requiring interpretation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Reach for AI when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The task requires judgement. Summarise an article, classifying open-ended free text into fuzzy categories.&lt;/li&gt;
&lt;li&gt;The input space is too large or unpredictable. You can't write an if statement for "understand what this customer is actually frustrated about" from a paragraph of free text.&lt;/li&gt;
&lt;li&gt;Some variability in output is fine, or even desirable. A creative writing assistant that gives the exact same suggestion every time isn't actually that useful.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  More examples than you asked for, because this pattern is everywhere
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Password strength meter.&lt;/strong&gt; "At least 8 characters, one number, one symbol" is a rule. Come on. We've been solving this since MySpace was a thing. No model needed, no matter how tempting "AI-powered password feedback" sounds on a feature list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flagging a support ticket as urgent.&lt;/strong&gt; If "urgent" just means "contains the word 'urgent' or 'broken'," that's a keyword check. If "urgent" means understanding the tone, the context, and the severity from a paragraph of a frustrated customer wrote at 2am, that's no longer a keyword problem. That's a language understanding problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Discount code validation.&lt;/strong&gt; "Is this code in our database and not expired?" is a lookup, full stop. Please don't ask a model to check a database for you; that's what the database is for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sorting a list by price.&lt;/strong&gt; Please don't spend $0.002 to rediscover ascending order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summarizing 200 pages of meeting notes into three takeaways.&lt;/strong&gt; A hard to write a rule for. This is a real, appropriate use of a model's judgement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writing a product description from a spec sheet.&lt;/strong&gt; Turning structured facts into natural, readable list is a language task. This is AI doing what it's actually good at.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cost of choosing the wrong tool
&lt;/h2&gt;

&lt;p&gt;This isn't just a complaint about over-engineering. Reaching for AI on an if-statement problem has real costs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Latency you didn't need to add. A local computation becomes a network request with inference time.&lt;/li&gt;
&lt;li&gt;Money you didn't need to spend. Each inference incurs a monetary cost that accumulates with usage. We've somehow managed to invent a subscription for if.&lt;/li&gt;
&lt;li&gt;Unpredictability you didn't ask for. If your business logic can quietly behave differently for the exact same input, you've turned a deterministic system into a probabilistic one. Now you get to debug "why did this work yesterday and not today" for a rule that used to just... work.&lt;/li&gt;
&lt;li&gt;A dependency you didn't need. Functionality becomes dependent on the availability, performance, and pricing of third-party AI services.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Reflect on our choices
&lt;/h2&gt;

&lt;p&gt;Before reaching for AI, ask: could I write this rule down in a sentence, and would that sentence still be true tomorrow? If yes, you probably want an if statement, not a model call. If the honest answer is "well, it depends, there's a lot of nuance, it's hard to actually pin down," that's usually the signal that you've found a problem AI is actually good at.&lt;/p&gt;

&lt;p&gt;AI earning its place in a product should feel like reaching for a tool that's uniquely suited to a hard problem, not like a reflex applied to everything because it's the exciting new thing to reach for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sometimes the most sophisticated piece of technology in the room is the engineer who knew not to call the model.&lt;/strong&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Google's guidance on when to use ML — from Google's own People + AI Guidebook, on evaluating whether a problem needs machine learning: &lt;a href="https://developers.google.com/machine-learning/guides/rules-of-ml" rel="noopener noreferrer"&gt;https://developers.google.com/machine-learning/guides/rules-of-ml&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Martin Fowler on YAGNI ("You Aren't Gonna Need It") — &lt;a href="https://lawsofsoftwareengineering.com/laws/yagni/" rel="noopener noreferrer"&gt;https://lawsofsoftwareengineering.com/laws/yagni/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Anthropic's guide to when (and when not) to use agents/LLMs — practical framing for deciding where a model call is actually justified: &lt;a href="https://www.google.com/search?client=firefox-b-d&amp;amp;q=Anthropic%27s+guide+to+when+%28and+when+not%29+to+use+agents" rel="noopener noreferrer"&gt;https://www.google.com/search?client=firefox-b-d&amp;amp;q=Anthropic%27s+guide+to+when+%28and+when+not%29+to+use+agents&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>What is a context window, actually?</title>
      <dc:creator>Alexandra</dc:creator>
      <pubDate>Wed, 22 Jul 2026 09:30:02 +0000</pubDate>
      <link>https://dev.to/ale3oula/what-is-a-context-window-actually-13l6</link>
      <guid>https://dev.to/ale3oula/what-is-a-context-window-actually-13l6</guid>
      <description>&lt;p&gt;AI is moving fast, and it feels like there's a new concept to learn every week. In an effort to actually understand this whole new world instead of just skimming past it, I've been writing ELI5 articles breaking down concepts that show up constantly in AI conversations but rarely get explained simply. This time, a term that gets thrown around a lot without much explanation: the context window.&lt;/p&gt;

&lt;h2&gt;
  
  
  AI 101 Recap
&lt;/h2&gt;

&lt;p&gt;The context window is the total number of input and output tokens an LLM can consider while generating a response. Your prompt, the conversation history, and even the model's response all share that same "budget" of tokens. As a conversation with an LLM grows longer, more tokens live in this window.&lt;/p&gt;

&lt;p&gt;So far so good. Every AI model has a limit on how many tokens it can hold in its "working memory" at once. So the interesting part with the context window is what happens when you reach these limits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why are there limits?
&lt;/h2&gt;

&lt;p&gt;There are several reasons models have context window limits. Processing more tokens requires more memory and computation, making every request slower and more expensive. On top of that, today's models struggle to use very long contexts effectively. They naturally pay more attention to the beginning and end of a conversation than the middle ("lost in the middle" problem).&lt;/p&gt;

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

&lt;p&gt;An AI model has no persistent memory between conversations. Within a long conversation, it only sees whatever still fits inside its context window. Think of it as a sliding window: as new messages come in, older ones eventually slide out and are no longer visible to the model.&lt;/p&gt;

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

&lt;p&gt;This is why a long conversation can feel like the model has "forgotten" something you told it early on. It doesn't actually forget, it just no longer has access to that part of the conversation, unless the product you're using has built something extra on top to handle it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How RAG helps
&lt;/h2&gt;

&lt;p&gt;RAG (retrieval-augmented generation) sounds technical, but the idea is simple: look it up before you answer, instead of guessing from memory.&lt;/p&gt;

&lt;p&gt;Think of the model as a smart intern who read a huge pile of general knowledge, but has never seen your company's internal docs. If you ask that intern a question about your product, you wouldn't expect them to know the answer off the top of their head.&lt;/p&gt;

&lt;p&gt;The flow looks more or less like this:&lt;/p&gt;

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

&lt;p&gt;That's RAG. Before generating a response, the system retrieves the most relevant pieces of information and adds only those to the prompt. Instead of searching through thousands of documents itself, the model receives just the information it needs.&lt;/p&gt;

&lt;p&gt;This fixes two problems at once:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;It solves the "too much to fit" problem.&lt;/strong&gt; You don't need to cram an entire wiki into the context window — just the relevant slice.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It solves the "the model doesn't know that" problem.&lt;/strong&gt; Training data has a cutoff and doesn't include your private docs. Retrieval hands the model current, specific facts instead of asking it to make something up.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's not magic, though. If the search step grabs the wrong page the model's answer will be wrong too. A RAG system is only as good as its retrieval step, not just the model doing the writing at the end.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why longer context isn't automatically better
&lt;/h2&gt;

&lt;p&gt;Newer models advertise huge context windows, sometimes hundreds of thousands of tokens. It's tempting to think the fix for all of this is simple: just make the window bigger, and pile everything in.&lt;/p&gt;

&lt;p&gt;Turns out that doesn't hold up as well as it sounds.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It costs more and takes longer. Every extra token in the prompt means more processing on every single request.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Models don't "read" a huge context evenly. They tend to pay attention to the start and the end of a long conversation, and quietly lose track of things in the middle.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;More text means more noise. A huge pile of context gives the model more chances to get distracted by something irrelevant, outdated, or conflicting. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A bigger context window isn't automatically better. It gives the model more information to work with, but also more opportunities to be distracted. That's why RAG matters: retrieving a small set of relevant information is usually more effective than hoping the model can make sense of everything at once.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Context windows&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.claude.com" rel="noopener noreferrer"&gt;Anthropic's context window documentation&lt;/a&gt; — official, model-specific limits and behavior&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://arxiv.org/abs/2307.03172" rel="noopener noreferrer"&gt;"Lost in the Middle: How Language Models Use Long Contexts"&lt;/a&gt; (Liu et al., 2023) — the research paper behind the finding that models underuse the middle of long contexts&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://platform.openai.com/docs/models" rel="noopener noreferrer"&gt;OpenAI's models documentation&lt;/a&gt; — useful for comparing how another provider frames the same constraint&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;RAG&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://arxiv.org/abs/2005.11401" rel="noopener noreferrer"&gt;"Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks"&lt;/a&gt; (Lewis et al., 2020) — the original RAG paper from Meta AI&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.pinecone.io/learn/retrieval-augmented-generation/" rel="noopener noreferrer"&gt;Pinecone's guide to RAG&lt;/a&gt; — practical, vendor-neutral explanation&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://python.langchain.com" rel="noopener noreferrer"&gt;LangChain RAG documentation&lt;/a&gt; — hands-on look at how RAG pipelines are built&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/what-is/retrieval-augmented-generation/" rel="noopener noreferrer"&gt;AWS: "What is RAG?"&lt;/a&gt; — plain-language explainer&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.ibm.com/topics/retrieval-augmented-generation" rel="noopener noreferrer"&gt;IBM: "What is retrieval-augmented generation?"&lt;/a&gt; — another accessible, non-technical framing&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>eli5</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
