<?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: Tetsuo TANAKA</title>
    <description>The latest articles on DEV Community by Tetsuo TANAKA (@tntetsu).</description>
    <link>https://dev.to/tntetsu</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%2F4216760%2Fcd4641da-7717-49ef-98e3-65dfffeb764c.png</url>
      <title>DEV Community: Tetsuo TANAKA</title>
      <link>https://dev.to/tntetsu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tntetsu"/>
    <language>en</language>
    <item>
      <title>In What Order Does a JavaScript Expression Run? Watching It Turn into a Value</title>
      <dc:creator>Tetsuo TANAKA</dc:creator>
      <pubDate>Thu, 19 Nov 2026 23:49:18 +0000</pubDate>
      <link>https://dev.to/tntetsu/in-what-order-does-a-javascript-expression-run-watching-it-turn-into-a-value-3b9b</link>
      <guid>https://dev.to/tntetsu/in-what-order-does-a-javascript-expression-run-watching-it-turn-into-a-value-3b9b</guid>
      <description>&lt;p&gt;In this series, we use &lt;a href="https://tntetsu.github.io/JSVisualizer/" rel="noopener noreferrer"&gt;JSVisualizer&lt;/a&gt;, a free browser-based tool, to understand classic algorithms by &lt;em&gt;watching&lt;/em&gt; them run. Last time we looked at functions.&lt;/p&gt;

&lt;p&gt;This time the topic is &lt;strong&gt;how expressions are evaluated&lt;/strong&gt; (evaluating an expression just means working out its value), and the star of the show is the &lt;strong&gt;Expr&lt;/strong&gt; view.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where beginners get stuck
&lt;/h2&gt;

&lt;p&gt;What ends up in &lt;code&gt;ok&lt;/code&gt; here?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The answer is &lt;code&gt;true&lt;/code&gt;. But faced with a line like line 5, it's easy to get lost:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Where does the calculation start?&lt;/strong&gt; &lt;code&gt;+&lt;/code&gt;, &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; are all in one expression. Does it go left to right, or in some other order?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What are the two sides of &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;?&lt;/strong&gt; Is &lt;code&gt;d&lt;/code&gt; paired with &lt;code&gt;10&lt;/code&gt;, or with all of &lt;code&gt;a + b * c &amp;gt; 10&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You can't see the middle.&lt;/strong&gt; &lt;code&gt;console.log(ok)&lt;/code&gt; only shows you the final result.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An expression is one line of code, but running it takes a series of small calculations. JSVisualizer's Expr view lays them out in a table, showing &lt;strong&gt;each part of the expression being replaced by its value, one stage at a time&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seeing it in the Expr view
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How to read it
&lt;/h3&gt;

&lt;p&gt;Paste the code into JSVisualizer, press &lt;strong&gt;▶ Run&lt;/strong&gt;, and open the &lt;strong&gt;Expr&lt;/strong&gt; tab. Press &lt;strong&gt;▷ Human&lt;/strong&gt; (one "human-friendly" step) four times to get through line 4. From here, switch to the finest step size, &lt;strong&gt;▶ Expr&lt;/strong&gt;. Keep pressing it until &lt;code&gt;b * c&lt;/code&gt; has been replaced by &lt;code&gt;12&lt;/code&gt; (about twelve presses):&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%2Fsazxkblkow8k7vjb4eiu.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%2Fsazxkblkow8k7vjb4eiu.png" alt="Full screen: on the left, line 5 is running; on the right, the Expr view shows a nine-row table from ok = a + b * c &gt; 10 &amp;amp;&amp;amp; d down to ok = true, with the row ok = 2 + 12 &gt; 10 &amp;amp;&amp;amp; d highlighted in blue" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Each row&lt;/strong&gt; is one stage of the expression. As you read down, parts of it are replaced by values.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The blue row&lt;/strong&gt; is the current stage. Pressing &lt;strong&gt;▶ Expr&lt;/strong&gt; moves you down the table. (Some presses stop on internal preparation, so the row won't always move.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bold blue text&lt;/strong&gt; is the part that will be calculated next.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An orange background&lt;/strong&gt; marks the part that was just replaced by a value.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The columns on the right&lt;/strong&gt; show the variables in the expression. The &lt;code&gt;ok&lt;/code&gt; column only fills in on the last row.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Reading from the top
&lt;/h3&gt;

&lt;p&gt;Here are just the expressions from the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ok = a + b * c &amp;gt; 10 &amp;amp;&amp;amp; d
ok = 2 + b * c &amp;gt; 10 &amp;amp;&amp;amp; d
ok = 2 + 3 * c &amp;gt; 10 &amp;amp;&amp;amp; d
ok = 2 + 3 * 4 &amp;gt; 10 &amp;amp;&amp;amp; d
ok = 2 + 12 &amp;gt; 10 &amp;amp;&amp;amp; d
ok = 14 &amp;gt; 10 &amp;amp;&amp;amp; d
ok = true &amp;amp;&amp;amp; d
ok = true &amp;amp;&amp;amp; true
ok = true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The variables turn into values one at a time. Then &lt;code&gt;3 * 4&lt;/code&gt; becomes &lt;code&gt;12&lt;/code&gt;, &lt;code&gt;2 + 12&lt;/code&gt; becomes &lt;code&gt;14&lt;/code&gt;, &lt;code&gt;14 &amp;gt; 10&lt;/code&gt; becomes &lt;code&gt;true&lt;/code&gt;, and finally &lt;code&gt;true &amp;amp;&amp;amp; true&lt;/code&gt; becomes &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the table reveals
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Operators have precedence
&lt;/h3&gt;

&lt;p&gt;In &lt;code&gt;2 + 3 * 4&lt;/code&gt;, the &lt;code&gt;*&lt;/code&gt; is applied before the &lt;code&gt;+&lt;/code&gt; to its left. The rule that decides which operator binds to which operands is called &lt;strong&gt;operator precedence&lt;/strong&gt;. Here are the operators in this expression, from highest to lowest precedence:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;*&lt;/code&gt; (multiply)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;+&lt;/code&gt; (add)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;gt;&lt;/code&gt; (compare)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; (and)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Since &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; has the lowest precedence, the whole expression means &lt;code&gt;(a + b * c &amp;gt; 10) &amp;amp;&amp;amp; d&lt;/code&gt;. Row 7, &lt;code&gt;true &amp;amp;&amp;amp; d&lt;/code&gt;, shows this directly: everything to the left of &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; has collapsed into a single value, so &lt;code&gt;d&lt;/code&gt; is paired with the whole left side.&lt;/p&gt;

&lt;p&gt;Note that the order in which variables are read is a separate thing from the order in which operators are applied. Look at rows 2–4: even though &lt;code&gt;*&lt;/code&gt; has higher precedence, the variables are replaced by their values left to right, &lt;code&gt;a&lt;/code&gt;, then &lt;code&gt;b&lt;/code&gt;, then &lt;code&gt;c&lt;/code&gt;. Only once the values are in place are the operators applied, &lt;code&gt;*&lt;/code&gt; before &lt;code&gt;+&lt;/code&gt;, following precedence.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. You can't write a range as &lt;code&gt;0 &amp;lt; x &amp;lt; 10&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;When operators with the same precedence appear in a row, the rule that decides which side they group from is called &lt;strong&gt;associativity&lt;/strong&gt;. &lt;code&gt;&amp;lt;&lt;/code&gt; groups from the left, and that can cause a surprising bug:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;inRange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;x&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="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inRange&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;x&lt;/code&gt; is 15, so "greater than 0 and less than 10" should be false. But this prints &lt;code&gt;true&lt;/code&gt;. Press &lt;strong&gt;▷ Human&lt;/strong&gt; once, then keep pressing &lt;strong&gt;▶ Expr&lt;/strong&gt; until you reach the row &lt;code&gt;true &amp;lt; 10&lt;/code&gt; (about eight presses) to see why:&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%2F4s9pmat88utcn7c6mbrx.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%2F4s9pmat88utcn7c6mbrx.png" alt="Expr view with four rows: inRange = 0 &lt; x &lt; 10, inRange = 0 &lt; 15 &lt; 10, inRange = true &lt; 10, inRange = true. The row true &lt; 10 is highlighted in blue" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0 &amp;lt; 15&lt;/code&gt; becomes &lt;code&gt;true&lt;/code&gt; first, which leaves the comparison &lt;strong&gt;&lt;code&gt;true &amp;lt; 10&lt;/code&gt;&lt;/strong&gt;. JavaScript treats &lt;code&gt;true&lt;/code&gt; as 1 when comparing, so that's &lt;code&gt;true&lt;/code&gt; too. Math notation doesn't carry over as is, and the Expr view lets you catch the odd step in the middle.&lt;/p&gt;

&lt;p&gt;The correct version is &lt;code&gt;0 &amp;lt; x &amp;amp;&amp;amp; x &amp;lt; 10&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The right side of &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; may never run
&lt;/h3&gt;

&lt;p&gt;In this next program, &lt;code&gt;null&lt;/code&gt; is a special value meaning "no value":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"yes"&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;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"no"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press &lt;strong&gt;▷ Human&lt;/strong&gt; once, then keep pressing &lt;strong&gt;▶ Expr&lt;/strong&gt; until the whole condition becomes &lt;code&gt;false&lt;/code&gt; (about nine presses):&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%2Fylkrn727pzwkc4mx95wi.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%2Fylkrn727pzwkc4mx95wi.png" alt="Expr view with four rows: user !== null &amp;amp;&amp;amp; user.age &gt;= 20, null !== null &amp;amp;&amp;amp; user.age &gt;= 20, false &amp;amp;&amp;amp; user.age &gt;= 20, false" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Look at row 3, &lt;code&gt;false &amp;amp;&amp;amp; user.age &amp;gt;= 20&lt;/code&gt;. The right side of &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; is &lt;strong&gt;still in its original form&lt;/strong&gt;. On the next row, the whole thing jumps straight to &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With boolean values like these, &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; gives &lt;code&gt;true&lt;/code&gt; only when both sides are &lt;code&gt;true&lt;/code&gt;, so if the left side is &lt;code&gt;false&lt;/code&gt;, the right side can't change the answer, and JavaScript doesn't evaluate it. This is called &lt;strong&gt;short-circuit evaluation&lt;/strong&gt;. &lt;code&gt;||&lt;/code&gt; (or) works the same way: if the left side is &lt;code&gt;true&lt;/code&gt;, the right side is skipped.&lt;/p&gt;

&lt;p&gt;(Strictly speaking, &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; and &lt;code&gt;||&lt;/code&gt; work with non-boolean values too: they check whether the left side counts as true or false and return the value of one of the operands. For example, &lt;code&gt;0 &amp;amp;&amp;amp; 123&lt;/code&gt; is &lt;code&gt;0&lt;/code&gt;, and &lt;code&gt;"hello" || 123&lt;/code&gt; is &lt;code&gt;"hello"&lt;/code&gt;.)&lt;/p&gt;

&lt;p&gt;Swapping the order makes the difference obvious. Change the condition to &lt;code&gt;user.age &amp;gt;= 20 &amp;amp;&amp;amp; user !== null&lt;/code&gt; and run it again, and the program stops with an error:&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%2Fb1bt4oser8o5qkpbf2if.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%2Fb1bt4oser8o5qkpbf2if.png" alt="Full screen: a Runtime Error at the bottom left says it cannot read properties of null or undefined; the Expr view on the right has stopped at the row null.age &gt;= 20 &amp;amp;&amp;amp; user !== null" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;null&lt;/code&gt; isn't an object, so you can't access properties on it. That's why the error happens as soon as the program tries to evaluate &lt;code&gt;null.age&lt;/code&gt;. Checking &lt;code&gt;user !== null &amp;amp;&amp;amp; ...&lt;/code&gt; first is a way of saying &lt;strong&gt;only calculate the right side when it's safe&lt;/strong&gt;.&lt;/p&gt;

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

&lt;p&gt;Open the link below and press &lt;strong&gt;▶ Run&lt;/strong&gt;; the Expr view opens. Use &lt;strong&gt;▷ Human&lt;/strong&gt; (the &lt;code&gt;h&lt;/code&gt; key) to reach the line you want, then step through it with &lt;strong&gt;▶ Expr&lt;/strong&gt; (the &lt;code&gt;→&lt;/code&gt; key) and back with &lt;strong&gt;◀ Expr&lt;/strong&gt; (&lt;code&gt;←&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://tntetsu.github.io/JSVisualizer/?code=https%3A%2F%2Ftntetsu.github.io%2FJSVisualizer%2Fsamples%2Farticles%2F04-expr.en.json&amp;amp;view=exprtrace" rel="noopener noreferrer"&gt;▶ Open in JSVisualizer (order of evaluation, Expr view)&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To change the code, press &lt;strong&gt;✏ Edit&lt;/strong&gt;. Before each run, &lt;strong&gt;predict&lt;/strong&gt; the rows in the middle of the table:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change &lt;code&gt;a + b * c&lt;/code&gt; to &lt;code&gt;(a + b) * c&lt;/code&gt;. Which part is calculated first now?&lt;/li&gt;
&lt;li&gt;Change &lt;code&gt;&amp;amp;&amp;amp; d&lt;/code&gt; to &lt;code&gt;|| d&lt;/code&gt;. Does &lt;code&gt;d&lt;/code&gt; get evaluated?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two more programs to play with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://tntetsu.github.io/JSVisualizer/?code=https%3A%2F%2Ftntetsu.github.io%2FJSVisualizer%2Fsamples%2Farticles%2F04-range.en.json&amp;amp;view=exprtrace" rel="noopener noreferrer"&gt;▶ Range check (0 &amp;lt; x &amp;lt; 10)&lt;/a&gt;&lt;/strong&gt;: what happens with &lt;code&gt;x = -5&lt;/code&gt;? Is there any &lt;code&gt;x&lt;/code&gt; that makes &lt;code&gt;0 &amp;lt; x &amp;lt; 10&lt;/code&gt; false?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://tntetsu.github.io/JSVisualizer/?code=https%3A%2F%2Ftntetsu.github.io%2FJSVisualizer%2Fsamples%2Farticles%2F04-shortcircuit.en.json&amp;amp;view=exprtrace" rel="noopener noreferrer"&gt;▶ Short-circuit evaluation&lt;/a&gt;&lt;/strong&gt;: change &lt;code&gt;let user = null;&lt;/code&gt; to &lt;code&gt;let user = { age: 25 };&lt;/code&gt;. How does the table change?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The Expr view shows parts of an expression being replaced by values, stage by stage. Bold blue is what's next; orange is what just changed.&lt;/li&gt;
&lt;li&gt;Operator precedence decides which operator is applied first, but variables are still read left to right.&lt;/li&gt;
&lt;li&gt;Comparison operators like &lt;code&gt;&amp;lt;&lt;/code&gt; group from the left (associativity). The &lt;code&gt;true &amp;lt; 10&lt;/code&gt; in the middle explains why &lt;code&gt;0 &amp;lt; x &amp;lt; 10&lt;/code&gt; misbehaves.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; and &lt;code&gt;||&lt;/code&gt; skip the right side when the left side already decides the result. The order of your conditions matters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Next up:&lt;/strong&gt; &lt;strong&gt;nested loops&lt;/strong&gt;. We'll run a multiplication table and a prime check in the &lt;strong&gt;Heatmap&lt;/strong&gt; view and see, in color, how many times each line ran.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>education</category>
      <category>visualization</category>
    </item>
    <item>
      <title>The First Step Was CLAUDE.md: How I Start a Project with Claude Code</title>
      <dc:creator>Tetsuo TANAKA</dc:creator>
      <pubDate>Tue, 17 Nov 2026 00:01:22 +0000</pubDate>
      <link>https://dev.to/tntetsu/the-first-step-was-claudemd-how-i-start-a-project-with-claude-code-9gc</link>
      <guid>https://dev.to/tntetsu/the-first-step-was-claudemd-how-i-start-a-project-with-claude-code-9gc</guid>
      <description>&lt;p&gt;This is part 2 of &lt;em&gt;My First Agentic Coding: Field Notes&lt;/em&gt;, a series about the five months I spent growing software through instructions to Claude Code alone, without writing a line of code myself. Each part covers one topic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In short:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"What should I do first?" In the three projects I started from an empty directory, the first step was always CLAUDE.md.&lt;/li&gt;
&lt;li&gt;I created the first version in three different ways: writing the requirements myself over about four hours, running &lt;code&gt;/init&lt;/code&gt; in an empty directory and answering four questions, and leaving it to Claude.&lt;/li&gt;
&lt;li&gt;None of those first versions was finished. Even a carefully written spec got overturned in use, and I added rules as I went.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When I started using Claude Code, my first thought was "What should I do first?"&lt;/p&gt;

&lt;p&gt;Looking back, in the three projects I started from an empty directory, CLAUDE.md (the project guide Claude Code reads at the start of a session) always came before the code. But I created it in a completely different way each time.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Project&lt;/th&gt;
&lt;th&gt;When&lt;/th&gt;
&lt;th&gt;How it started&lt;/th&gt;
&lt;th&gt;First version&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A web app for an experiment&lt;/td&gt;
&lt;td&gt;May 15, 2026&lt;/td&gt;
&lt;td&gt;I wrote the requirements and had Claude review them&lt;/td&gt;
&lt;td&gt;178 lines&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JSInterpreter&lt;/td&gt;
&lt;td&gt;May 23, 2026&lt;/td&gt;
&lt;td&gt;I ran &lt;code&gt;/init&lt;/code&gt; in an empty directory and answered four questions&lt;/td&gt;
&lt;td&gt;75 lines&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JSVisualizer&lt;/td&gt;
&lt;td&gt;May 25, 2026&lt;/td&gt;
&lt;td&gt;Claude wrote it along with the design documents&lt;/td&gt;
&lt;td&gt;154 lines&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The experiment web app at the top of the table is the earliest agentic coding project I have records of. In this post, I go through these three in order, then cover what to do when you already have code. &lt;a href="https://dev.to/tntetsu/five-months-without-writing-a-line-of-code-the-basic-loop-of-agentic-coding-4akd"&gt;Part 1&lt;/a&gt; describes how I ran the projects as a whole.&lt;/p&gt;

&lt;p&gt;The quotes from my sessions below are translated from Japanese, except where Claude answered in English.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing out the requirements: the experiment web app
&lt;/h2&gt;

&lt;p&gt;The first thing I built was a small web app for an experiment comparing sounds by ear. On the evening of May 15, I ran &lt;code&gt;/init&lt;/code&gt; and immediately asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Please create a CLAUDE.md for a Node application. It will use Firebase.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From there, I added requirements one sentence at a time: the purpose of the experiment, the features, the screen layout, the list specification. For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;New entries and updates shall use the same screen layout, and an update shall show the registered data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Along the way, I caught one of my own wrong assumptions: "It's not a Node.js application. It's a web application." With no code yet, only the text had to change.&lt;/p&gt;

&lt;p&gt;Once the requirements were written, I asked Claude for a review:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Please review CLAUDE.md. Point out anything missing, anything ambiguous, and anything that should be improved.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I fixed what it pointed out (I believe I had Claude do most of the fixing) and said "Please review it again." We went around several times. Where I didn't know something, I said so and left it to Claude:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I don't really know about the detailed frontend stack, so please recommend something suitable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The finished 178-line CLAUDE.md was essentially a requirements document. It took about four hours. I remember working hard on it.&lt;/p&gt;

&lt;p&gt;Today I might keep the requirements in a separate document, but at the time I put everything in CLAUDE.md. This article isn't a guide to how CLAUDE.md should be structured; it's a record of how I actually started using it.&lt;/p&gt;

&lt;p&gt;That file was the only thing in the first commit. Five days later, on May 20, my only instruction was "Implement it."&lt;/p&gt;

&lt;h2&gt;
  
  
  Even a careful spec gets overturned in use
&lt;/h2&gt;

&lt;p&gt;The CLAUDE.md I had worked so hard on became the foundation of the implementation, but what I wrote wasn't always right.&lt;/p&gt;

&lt;p&gt;For audio playback, I had written in CLAUDE.md that sound would be "processed using the Web Audio API." Once the app was working, I asked Claude where the code that played the sound was. After seeing the answer, I asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Shouldn't it use the HTML audio element?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude's reply began with "The CLAUDE.md spec says this." It went on to explain that changing the length with the &lt;code&gt;&amp;lt;audio&amp;gt;&lt;/code&gt; element's &lt;code&gt;playbackRate&lt;/code&gt; would also change the pitch, so the app used the Web Audio API instead. My own spec was being used to argue against me.&lt;/p&gt;

&lt;p&gt;But that explanation was wrong.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Changing the length with the audio element's playbackRate doesn't change the pitch. The current implementation seems to sound much worse than the audio element. Please change it to use the audio element.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;On the &lt;code&gt;&amp;lt;audio&amp;gt;&lt;/code&gt; element, the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/preservesPitch" rel="noopener noreferrer"&gt;&lt;code&gt;preservesPitch&lt;/code&gt;&lt;/a&gt; property controls whether the pitch is kept when &lt;code&gt;playbackRate&lt;/code&gt; changes. It defaults to &lt;code&gt;true&lt;/code&gt;, so normally the pitch stays the same when you change the playback speed. Meanwhile, the Web Audio API implementation at the time sounded noticeably worse to me, so I had Claude switch to an implementation that uses the &lt;code&gt;&amp;lt;audio&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;I took three things from this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Even a spec you wrote yourself can feel wrong once you use the result.&lt;/li&gt;
&lt;li&gt;"It's in CLAUDE.md" is strong evidence as far as Claude is concerned.&lt;/li&gt;
&lt;li&gt;Claude's explanations need checking too.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There was one more trap. The implementation moved to the &lt;code&gt;&amp;lt;audio&amp;gt;&lt;/code&gt; element, but &lt;strong&gt;CLAUDE.md still said "Web Audio API" right up to the last commit.&lt;/strong&gt; Changing the implementation doesn't change CLAUDE.md by itself, and I hadn't asked for that.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;/init&lt;/code&gt; in an empty directory: JSInterpreter
&lt;/h2&gt;

&lt;p&gt;The next project, a JavaScript interpreter called JSInterpreter, started in a completely different way.&lt;/p&gt;

&lt;p&gt;On the night of May 23, I ran &lt;code&gt;/init&lt;/code&gt; in an empty directory. Claude noticed the directory was empty and offered two options:&lt;/p&gt;

&lt;blockquote&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a starter CLAUDE.md&lt;/strong&gt; for a JavaScript interpreter project you're about to build&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wait&lt;/strong&gt; until you've added some source files, then re-run &lt;code&gt;/init&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt;

&lt;p&gt;I answered "1," and four multiple-choice questions followed.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Question&lt;/th&gt;
&lt;th&gt;My answer&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;What language to write it in&lt;/td&gt;
&lt;td&gt;JavaScript&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;How much of the syntax to cover&lt;/td&gt;
&lt;td&gt;Modern ES6+&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;How to execute programs&lt;/td&gt;
&lt;td&gt;Tree-walk interpreter&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Which test framework&lt;/td&gt;
&lt;td&gt;Jest&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;About three minutes later, Claude had finished writing CLAUDE.md. All I did afterward was ask Claude to translate it into Japanese. The CLAUDE.md in the &lt;a href="https://github.com/tntetsu/JSInterpreter/commit/ee1ce81" rel="noopener noreferrer"&gt;first commit&lt;/a&gt; is exactly that translation.&lt;/p&gt;

&lt;p&gt;It's easy, but &lt;strong&gt;because it's written before the code, the first version is a prediction of what you're about to build.&lt;/strong&gt; Sure enough, it mentions a name, &lt;code&gt;LoxClass&lt;/code&gt;, that doesn't exist in the finished code, and it says nothing about the debugger I built later. Claude itself hinted at this when it finished:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As you start adding source files, re-run &lt;code&gt;/init&lt;/code&gt; to refine this with specifics from the actual code.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Three days later, in &lt;a href="https://github.com/tntetsu/JSInterpreter/commit/42e4873" rel="noopener noreferrer"&gt;&lt;code&gt;42e4873&lt;/code&gt;&lt;/a&gt;, CLAUDE.md was rewritten into a 146-line version that matched the implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Leaving it to Claude: JSVisualizer
&lt;/h2&gt;

&lt;p&gt;For JSVisualizer, a visualization tool built on JSInterpreter, I left CLAUDE.md to Claude. At &lt;a href="https://github.com/tntetsu/JSVisualizer/commit/ea3d857" rel="noopener noreferrer"&gt;&lt;code&gt;ea3d857&lt;/code&gt;&lt;/a&gt; (May 25), there wasn't a single line of code, yet the README and design documents were already there alongside CLAUDE.md.&lt;/p&gt;

&lt;p&gt;From the first version, it had a section on key design decisions and assumed JSInterpreter's API. I think having that foundation in place is why the first version was so substantial.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The wording of my instruction can't be verified because the session log no longer exists. My only evidence that Claude wrote it is my memory and the Co-Authored-By line.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  If you already have code, start there
&lt;/h2&gt;

&lt;p&gt;So far, I've been talking about empty directories. But I suspect many people starting out already have code. In that case, &lt;strong&gt;I think the easiest first step of all is to run &lt;code&gt;/init&lt;/code&gt; in that directory.&lt;/strong&gt; Claude can read the real thing, so mismatches with a prediction, like &lt;code&gt;LoxClass&lt;/code&gt;, should be less likely.&lt;/p&gt;

&lt;p&gt;It doesn't matter if you didn't write the code yourself. Both of my examples began with a different AI.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Code and nothing else&lt;/strong&gt; (October 2026): a small browser-based tool for measuring sound. As I remember it, the code came from Gemini. I created CLAUDE.md with &lt;code&gt;/init&lt;/code&gt;, then asked "First, please run git init." Claude wrote the README too. So even code that isn't under version control yet can be set up this way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A settings file from another agent&lt;/strong&gt; (June 2026): a web app that supports oral exams in my classes. It already had a &lt;code&gt;GEMINI.md&lt;/code&gt; for Gemini. The CLAUDE.md that appeared the next day has the same headings and looks like it was carried over and extended. So you don't have to throw that file away. You can build on it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keep in mind, though, that code only shows how things are now. What you want to build and what you want protected are things you'll need to add yourself. The rules in the next section are examples of that.&lt;/p&gt;

&lt;h2&gt;
  
  
  How CLAUDE.md grew
&lt;/h2&gt;

&lt;p&gt;JSVisualizer's CLAUDE.md went through 48 updates and roughly tripled in a little over five months.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Size&lt;/th&gt;
&lt;th&gt;What happened&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;May 25&lt;/td&gt;
&lt;td&gt;154 lines / 6.9 KB&lt;/td&gt;
&lt;td&gt;First version&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;June 3&lt;/td&gt;
&lt;td&gt;331 lines / 21 KB&lt;/td&gt;
&lt;td&gt;Updated along with new features&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;July 23&lt;/td&gt;
&lt;td&gt;431 lines / 38 KB&lt;/td&gt;
&lt;td&gt;Updated to match the actual code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;September 29&lt;/td&gt;
&lt;td&gt;451 lines / 47 KB&lt;/td&gt;
&lt;td&gt;Fixed outdated descriptions of the Lifetime view&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;November 2&lt;/td&gt;
&lt;td&gt;452 lines / 51 KB&lt;/td&gt;
&lt;td&gt;"Key design decisions" reached 47 items&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Most of this came from me saying "Document this and commit." Claude wrote the content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Working rules were a different story: I added them myself whenever I ran into a problem or noticed something.&lt;/strong&gt; On May 24, in JSInterpreter, I asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Please add to CLAUDE.md that regression tests must always be run after changing code, and that the documentation must be updated.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude wrote &lt;a href="https://github.com/tntetsu/JSInterpreter/commit/24cb8a1" rel="noopener noreferrer"&gt;this rule&lt;/a&gt; (excerpt, translated):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Required steps when changing code
&lt;/span&gt;
When you change source code (under &lt;span class="sb"&gt;`src/`&lt;/span&gt;), &lt;span class="gs"&gt;**always do both of the following**&lt;/span&gt;.

&lt;span class="gu"&gt;### 1. Run the regression tests
&lt;/span&gt;
Confirm that all 185 tests pass before committing. If a test fails, do not commit.

&lt;span class="gu"&gt;### 2. Update the documentation
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In JSVisualizer, on November 2, I added a commitment not to delete or rename files that my article series links to. Doing so would break the links in published articles.&lt;/p&gt;

&lt;p&gt;That said, CLAUDE.md doesn't have to keep growing. JSInterpreter's has stayed at 146 lines since May 26, and the only changes since then have been to the test count.&lt;/p&gt;

&lt;p&gt;I'll cover what happens when CLAUDE.md gets long in part 4.&lt;/p&gt;

&lt;h2&gt;
  
  
  If I were starting tomorrow
&lt;/h2&gt;

&lt;p&gt;I can't tell you which approach is best. Here is what I would do in each situation.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Situation&lt;/th&gt;
&lt;th&gt;First step&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;You can describe what you want to build&lt;/td&gt;
&lt;td&gt;Give the requirements as a list and ask for a review&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It's still vague&lt;/td&gt;
&lt;td&gt;Run &lt;code&gt;/init&lt;/code&gt; in an empty directory and answer the questions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You have a related project&lt;/td&gt;
&lt;td&gt;Have Claude read it and write CLAUDE.md&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You already have code&lt;/td&gt;
&lt;td&gt;Run &lt;code&gt;/init&lt;/code&gt; in that directory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;You have another agent's settings file&lt;/td&gt;
&lt;td&gt;Have Claude write CLAUDE.md based on it&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here are two instructions you can use as they are. I sent both myself (translated here).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Please review CLAUDE.md. Point out anything missing, anything ambiguous, and anything that should be improved.
&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;Please add to CLAUDE.md that regression tests must always be run after changing code, and that the documentation must be updated.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In part 1, I said not to try to write a perfect specification up front, so the experiment web app may look like the opposite. The difference is how settled the work was. The requirements were clear, so I could write them all out first. JSInterpreter was something I was exploring, and four answers were enough to begin with.&lt;/p&gt;

&lt;p&gt;The three starts were different, but they had one thing in common: the first CLAUDE.md was never finished. Whether I spent four hours writing it, made it in three minutes, or left it to Claude, I had to rewrite it once implementation got going. How much detail you put in at the start may matter less than whether you keep fixing it as you go.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;I can't rank these approaches.&lt;/strong&gt; The projects differ, and so did my experience at the time. The effort may have dropped simply because I was getting used to it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"First" means first on record.&lt;/strong&gt; I may have tried it before then, but I don't remember.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Some logs no longer exist.&lt;/strong&gt; I can't verify the text of Claude's review comments on May 15, the wording of my instructions for JSVisualizer's first version and for &lt;code&gt;42e4873&lt;/code&gt;, or the instruction that created the oral exam app's CLAUDE.md.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The behavior of &lt;code&gt;/init&lt;/code&gt; is as of May 2026.&lt;/strong&gt; The current version may not ask the same questions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] If you can describe what you want to build, write it in CLAUDE.md before the code.&lt;/li&gt;
&lt;li&gt;[ ] If it's hard to describe, run &lt;code&gt;/init&lt;/code&gt; in an empty directory and answer the questions.&lt;/li&gt;
&lt;li&gt;[ ] If you already have code, run &lt;code&gt;/init&lt;/code&gt; in that directory.&lt;/li&gt;
&lt;li&gt;[ ] When you don't know which technology to choose, say so and ask for a recommendation.&lt;/li&gt;
&lt;li&gt;[ ] Ask for a review of CLAUDE.md before implementation.&lt;/li&gt;
&lt;li&gt;[ ] Once code exists, have the first version's predictions corrected to match the implementation.&lt;/li&gt;
&lt;li&gt;[ ] When the implementation departs from the spec, ask for CLAUDE.md to be updated too.&lt;/li&gt;
&lt;li&gt;[ ] Add working rules you want followed every time to CLAUDE.md.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Next time
&lt;/h2&gt;

&lt;p&gt;Next time: "I let the AI decide whether to write an ADR." I'll cover what happened when I left the decision about what to record to the AI, and how the ADRs it wrote recorded the implementation rather than my intent.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The May exchanges in this post used Claude Sonnet 4.6.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claudecode</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>What Really Happens When You Call a Function? Watching the Call Stack</title>
      <dc:creator>Tetsuo TANAKA</dc:creator>
      <pubDate>Fri, 13 Nov 2026 00:22:34 +0000</pubDate>
      <link>https://dev.to/tntetsu/what-really-happens-when-you-call-a-function-watching-the-call-stack-3mj5</link>
      <guid>https://dev.to/tntetsu/what-really-happens-when-you-call-a-function-watching-the-call-stack-3mj5</guid>
      <description>&lt;p&gt;In this series, we use &lt;a href="https://tntetsu.github.io/JSVisualizer/" rel="noopener noreferrer"&gt;JSVisualizer&lt;/a&gt;, a free browser-based tool, to understand classic algorithms by &lt;em&gt;watching&lt;/em&gt; them run. Last time we looked at conditionals.&lt;/p&gt;

&lt;p&gt;This time the topic is &lt;strong&gt;functions&lt;/strong&gt;, and the star of the show is the &lt;strong&gt;Call Stack&lt;/strong&gt; view.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where beginners get stuck
&lt;/h2&gt;

&lt;p&gt;This program adds the squares of two numbers. &lt;code&gt;3 * 3 + 4 * 4&lt;/code&gt; is 25.&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;square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;x&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;sumOfSquares&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;square&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="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="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sumOfSquares&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&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;What does the last line, &lt;code&gt;console.log(x)&lt;/code&gt;, print? People who've just met functions often wonder:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;x&lt;/code&gt; shows up in three places.&lt;/strong&gt; It's a parameter (a variable that receives a value passed to a function) of &lt;code&gt;square&lt;/code&gt;, a parameter of &lt;code&gt;sumOfSquares&lt;/code&gt;, and the &lt;code&gt;let x&lt;/code&gt; outside. Are these the same thing or different things?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Where does execution go when you call a function, and how does it get back?&lt;/strong&gt; Partway through &lt;code&gt;square(x) + square(y)&lt;/code&gt;, the program jumps into another function. How does it know where to pick up again?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;If a function changes a value, does the change reach the outside?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JSVisualizer's Call Stack view shows you exactly this: &lt;strong&gt;each function call gets its own frame, which appears when the call starts and is removed from the call stack when it ends&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seeing it in the Call Stack view
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How to read it
&lt;/h3&gt;

&lt;p&gt;Paste the code into JSVisualizer, press &lt;strong&gt;▶ Run&lt;/strong&gt;, and open the &lt;strong&gt;Call Stack&lt;/strong&gt; tab. Then press &lt;strong&gt;▷ Human&lt;/strong&gt; (one "human-friendly" step) three times:&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%2Fhzb98dsq16zusu9wvvxp.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%2Fhzb98dsq16zusu9wvvxp.png" alt="Call Stack view: Global holds x = 10 and more; below it, sumOfSquares(3, 4) holds x = 3 and y = 4" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each box is called a &lt;strong&gt;frame&lt;/strong&gt;. Every time you call a function, a new frame is created just for that call, and the Call Stack view shows the variables that belong to each frame along with their values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Global&lt;/strong&gt; is a special box that shows the variables (and other names) outside any function. It's always at the top. &lt;code&gt;square = ƒ square&lt;/code&gt; means there's a function named &lt;code&gt;square&lt;/code&gt;, and &lt;code&gt;answer = —&lt;/code&gt; means &lt;code&gt;answer&lt;/code&gt; doesn't have a value yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;sumOfSquares(3, 4)&lt;/code&gt;&lt;/strong&gt; is the frame for the call we just made. Its heading shows the values that were passed in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The blue outline&lt;/strong&gt; marks the frame that's running right now.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;sumOfSquares&lt;/code&gt; frame has &lt;code&gt;x = 3&lt;/code&gt;, while Global has &lt;code&gt;x = 10&lt;/code&gt;. Same name, but they live in different places: they're two separate variables.&lt;/p&gt;

&lt;h3&gt;
  
  
  Calls pile up
&lt;/h3&gt;

&lt;p&gt;Press &lt;strong&gt;▷ Human&lt;/strong&gt; six more times (nine in total), and look at the whole screen:&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%2Frnyb4s1e53r9plj31prs.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%2Frnyb4s1e53r9plj31prs.png" alt="Full screen: on the left, line 2 (return x * x) is running and square(y) on line 6 has a dashed purple underline; on the right, Global has x = 10, square(4) has x = 4, and sumOfSquares(3, 4) has x = 3 and y = 4" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On the left, line 2 inside &lt;code&gt;square&lt;/code&gt; is running, and the call that got us here, &lt;code&gt;square(y)&lt;/code&gt;, has a dashed purple underline.&lt;/li&gt;
&lt;li&gt;On the right, a &lt;code&gt;square(4)&lt;/code&gt; frame has appeared under Global, pushing &lt;code&gt;sumOfSquares(3, 4)&lt;/code&gt; down. New frames always appear right below Global.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now look at &lt;code&gt;x&lt;/code&gt;: &lt;strong&gt;it's 10 in Global, 4 in &lt;code&gt;square(4)&lt;/code&gt;, and 3 in &lt;code&gt;sumOfSquares(3, 4)&lt;/code&gt;&lt;/strong&gt;. Three variables with the same name exist at the same time, with three different values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Frames are removed
&lt;/h3&gt;

&lt;p&gt;Press &lt;strong&gt;▷ Human&lt;/strong&gt; five more times (14 in total):&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%2Fljsujjtq620gbdxlojjz.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%2Fljsujjtq620gbdxlojjz.png" alt="Call Stack view: only Global remains, with x = 10 and answer = 25" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a function finishes running, its frame is removed from the call stack. Only Global is left on screen, and &lt;code&gt;answer&lt;/code&gt; now holds 25. Global's &lt;code&gt;x&lt;/code&gt; is &lt;strong&gt;still 10&lt;/strong&gt;. That's what the final &lt;code&gt;console.log(x)&lt;/code&gt; prints.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the frames reveal
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Same name, different frame, different variable
&lt;/h3&gt;

&lt;p&gt;A function's parameters and the variables declared inside it belong to that one call. Here, when &lt;code&gt;square&lt;/code&gt; says &lt;code&gt;x&lt;/code&gt;, it means &lt;code&gt;square&lt;/code&gt;'s parameter &lt;code&gt;x&lt;/code&gt;. There's a variable with the same name outside, but it's a separate variable.&lt;/p&gt;

&lt;p&gt;The region of code from which a variable can be referred to is called its &lt;strong&gt;scope&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Be careful: scope is a different idea from frames and the call stack. The call stack is the pile of function calls currently running, so it shows which function called which. Scope in JavaScript, on the other hand, depends not on where a function is called from but on &lt;strong&gt;where the function is written in the code (where it's defined)&lt;/strong&gt;. For example, &lt;code&gt;square&lt;/code&gt; is called from &lt;code&gt;sumOfSquares&lt;/code&gt;, but code inside &lt;code&gt;square&lt;/code&gt; can't use &lt;code&gt;sumOfSquares&lt;/code&gt;'s &lt;code&gt;y&lt;/code&gt;. Seeing the &lt;code&gt;sumOfSquares(3, 4)&lt;/code&gt; frame below the &lt;code&gt;square(4)&lt;/code&gt; frame in the Call Stack view only tells you the order of the calls; it doesn't mean &lt;code&gt;square&lt;/code&gt; can see &lt;code&gt;sumOfSquares&lt;/code&gt;'s variables.&lt;/p&gt;

&lt;p&gt;This is why you can write a function without worrying about what variable names its callers happen to use.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The newest call finishes first
&lt;/h3&gt;

&lt;p&gt;Step through and watch the frames:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The &lt;code&gt;sumOfSquares(3, 4)&lt;/code&gt; frame appears&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;square(3)&lt;/code&gt; frame appears, then is removed when it finishes&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;square(4)&lt;/code&gt; frame appears, then is removed when it finishes&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;sumOfSquares(3, 4)&lt;/code&gt; frame is removed&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;The most recent frame is always the first to go&lt;/strong&gt;, just like taking plates off the top of a pile. A pile that works this way is called a &lt;strong&gt;stack&lt;/strong&gt;, and since this one is made of function calls, it's the &lt;strong&gt;call stack&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Notice that the &lt;code&gt;sumOfSquares&lt;/code&gt; frame stays put while &lt;code&gt;square&lt;/code&gt; runs. That's how execution can pick up where it left off in &lt;code&gt;square(x) + square(y)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;One note: this article is about ordinary &lt;strong&gt;synchronous&lt;/strong&gt; calls, where the caller waits for the function to finish before moving on. With &lt;strong&gt;asynchronous&lt;/strong&gt; code (&lt;code&gt;setTimeout&lt;/code&gt;, &lt;code&gt;async&lt;/code&gt;/&lt;code&gt;await&lt;/code&gt;), the rest of a function runs later as a separate job, so "frames pile up and come off the top" isn't the whole story. JSVisualizer doesn't reproduce real asynchronous behavior either, so this series sticks to synchronous code.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Assigning to a parameter doesn't change the caller's variable
&lt;/h3&gt;

&lt;p&gt;What does this program print?&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;addOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n&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="n"&gt;n&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="nf"&gt;addOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&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;Not 11. Pausing inside &lt;code&gt;addOne&lt;/code&gt; shows why:&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%2Fafsl3xtlbeobmwwhfcvn.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%2Fafsl3xtlbeobmwwhfcvn.png" alt="Call Stack view: Global has n = 10, and addOne(10) has n = 11" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;n&lt;/code&gt; in the &lt;code&gt;addOne(10)&lt;/code&gt; frame has become 11, but Global's &lt;code&gt;n&lt;/code&gt; is still 10. A function doesn't receive the variable itself. It receives &lt;strong&gt;a copy of its value&lt;/strong&gt;. With numbers like this, assigning a new value to the parameter inside the function has no effect on the caller's variable. (With arrays and objects, the caller and the function can end up sharing the same object; we'll get to that later in the series.)&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%2F1z3n3f4n1h2mla5rrjx4.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%2F1z3n3f4n1h2mla5rrjx4.png" alt="Call Stack view: the addOne frame is gone, only Global with n = 10 remains, and the console shows 10" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the function ends, the &lt;code&gt;addOne&lt;/code&gt; frame is removed from the call stack. &lt;code&gt;return n&lt;/code&gt; hands back 11, but the caller doesn't use that value, so Global's &lt;code&gt;n&lt;/code&gt; stays 10. Write &lt;code&gt;n = addOne(n);&lt;/code&gt; and the returned 11 is stored in Global's &lt;code&gt;n&lt;/code&gt;.&lt;/p&gt;

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

&lt;p&gt;Open the link below and press &lt;strong&gt;▶ Run&lt;/strong&gt;; the Call Stack view opens. Step forward with &lt;strong&gt;▷ Human&lt;/strong&gt; (the &lt;code&gt;h&lt;/code&gt; key) and back with &lt;strong&gt;◁ Human&lt;/strong&gt; (&lt;code&gt;H&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://tntetsu.github.io/JSVisualizer/?code=https%3A%2F%2Ftntetsu.github.io%2FJSVisualizer%2Fsamples%2Farticles%2F03-square.en.json&amp;amp;view=state" rel="noopener noreferrer"&gt;▶ Open in JSVisualizer (sum of squares, Call Stack view)&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To change the code, press &lt;strong&gt;✏ Edit&lt;/strong&gt;. Before each run, &lt;strong&gt;predict&lt;/strong&gt; how the frames will behave:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change &lt;code&gt;sumOfSquares(3, 4)&lt;/code&gt; to &lt;code&gt;sumOfSquares(square(2), 4)&lt;/code&gt;. Which frame appears first?&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;console.log(y);&lt;/code&gt; at the very end. What happens, and why?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One more program to play with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://tntetsu.github.io/JSVisualizer/?code=https%3A%2F%2Ftntetsu.github.io%2FJSVisualizer%2Fsamples%2Farticles%2F03-param.en.json&amp;amp;view=state" rel="noopener noreferrer"&gt;▶ Changing a parameter inside a function&lt;/a&gt;&lt;/strong&gt;: change &lt;code&gt;addOne(n);&lt;/code&gt; to &lt;code&gt;n = addOne(n);&lt;/code&gt;. When does Global's &lt;code&gt;n&lt;/code&gt; change?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Calling a function creates a frame just for that call. When the call ends, the frame is removed from the call stack.&lt;/li&gt;
&lt;li&gt;A function's parameters and local variables are separate for each call, and separate from any outside variable with the same name. The Call Stack view shows them side by side, with different values. Which variables code can refer to (its scope) depends on where the function is written, not on who called it.&lt;/li&gt;
&lt;li&gt;The newest frame is the first to go. A function receives a copy of a value, so assigning to a number parameter inside doesn't change the caller's variable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Next up:&lt;/strong&gt; &lt;strong&gt;how expressions are evaluated&lt;/strong&gt;. We'll use the &lt;strong&gt;Expr&lt;/strong&gt; view to see the order in which a complicated expression like &lt;code&gt;a + b * c &amp;gt; 10 &amp;amp;&amp;amp; d&lt;/code&gt; gets worked out.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>education</category>
      <category>visualization</category>
    </item>
    <item>
      <title>Five Months Without Writing a Line of Code: The Basic Loop of Agentic Coding</title>
      <dc:creator>Tetsuo TANAKA</dc:creator>
      <pubDate>Tue, 10 Nov 2026 00:22:46 +0000</pubDate>
      <link>https://dev.to/tntetsu/five-months-without-writing-a-line-of-code-the-basic-loop-of-agentic-coding-4akd</link>
      <guid>https://dev.to/tntetsu/five-months-without-writing-a-line-of-code-the-basic-loop-of-agentic-coding-4akd</guid>
      <description>&lt;p&gt;This is part 1 of &lt;em&gt;My First Agentic Coding: Field Notes&lt;/em&gt;, a series about the five months I spent growing software through instructions to Claude Code alone, without writing a line of code myself. Each part covers one topic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In short:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For five months, I built a tool that visualizes JavaScript execution using only instructions to Claude Code. I did not write a single line of code.&lt;/li&gt;
&lt;li&gt;The basic pattern: delegate the broad strokes of a new feature, then give detailed instructions when something feels wrong in use. You can reject an approach as early as the plan stage.&lt;/li&gt;
&lt;li&gt;You don't need to know the name of a technique to give detailed instructions. Describe the behavior in your own words, and the AI can tell you what the technique is called.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I'm building &lt;a href="https://tntetsu.github.io/JSVisualizer/" rel="noopener noreferrer"&gt;JSVisualizer&lt;/a&gt;, a web app that runs a JavaScript program one step at a time and shows what happens through 12 different views. You can watch variables change, see the tree of function calls, inspect arrays, and step forward and backward. &lt;a href="https://dev.to/tntetsu/see-your-javascript-run-12-different-ways-meet-jsvisualizer-and-how-it-differs-from-python-tutor-1kk5"&gt;A separate series&lt;/a&gt; introduces the tool itself. This one is about how it was made.&lt;/p&gt;

&lt;p&gt;Here is the scale of the work as of November 2, 2026:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSVisualizer: 147 commits and 48 ADRs, started May 25, 2026&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/tntetsu/JSInterpreter" rel="noopener noreferrer"&gt;JSInterpreter&lt;/a&gt;, the JavaScript interpreter it depends on: 52 commits, started May 23&lt;/li&gt;
&lt;li&gt;In use in a first-year university class since September 30, 2026&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I &lt;strong&gt;did not write a single line of code&lt;/strong&gt; in these projects. Everything was done through natural-language instructions to Claude Code and documentation in CLAUDE.md and ADRs (Architecture Decision Records).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Terms used in this post&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Agentic coding&lt;/strong&gt;: a way of developing where an AI agent reads and writes files and runs commands itself, while a human gives instructions in natural language and checks the results&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Claude Code&lt;/strong&gt;: Anthropic's coding agent, used from a terminal or an editor&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CLAUDE.md&lt;/strong&gt;: a project guide that Claude Code reads at the start of a session&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ADR&lt;/strong&gt;: a short document recording one design decision and the reasons behind it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Plan mode&lt;/strong&gt;: a Claude Code mode that has Claude present a plan before implementing anything&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before going further, here is my background and how I checked the work.&lt;/p&gt;

&lt;p&gt;I spent more than 20 years in software research and development in industry, and I have now been teaching software at a university for more than 16 years. Later in this post, I'll describe where that experience helped and where I relied on asking Claude.&lt;/p&gt;

&lt;p&gt;I have read almost none of the code Claude wrote. I skimmed it at first out of curiosity, then stopped reading it entirely. When I had a question about how something was built, I asked Claude in natural language and gave instructions the same way. I checked behavior by using the software myself, and I also asked for tests. However, I left the test cases to Claude and have not verified their coverage.&lt;/p&gt;

&lt;p&gt;In this series, I look back on that way of working and try to put it into words. My materials are the git history, the ADRs, the history of CLAUDE.md, and the Claude Code session logs. I reread them together with Claude and checked them against my memory. Several times, that rereading overturned what I thought I knew. Those moments are part of the story too.&lt;/p&gt;

&lt;p&gt;The first half of the series will cover:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The basic loop of agentic coding (this post)&lt;/li&gt;
&lt;li&gt;The first step was CLAUDE.md: how to start a project&lt;/li&gt;
&lt;li&gt;I let the AI decide whether to write an ADR&lt;/li&gt;
&lt;li&gt;The AI reads old documents and writes new mistakes&lt;/li&gt;
&lt;li&gt;Reviewing AI-assisted development with AI: vanishing logs, lagging git, and conflicting memories&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The quotes from my sessions below are translated from Japanese.&lt;/p&gt;

&lt;h2&gt;
  
  
  The basic loop
&lt;/h2&gt;

&lt;p&gt;Over those five months, I repeated this loop for each feature:&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%2F5wg1q8hzbos6eg2fpqwy.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%2F5wg1q8hzbos6eg2fpqwy.png" alt="The basic loop: give the broad strokes, Claude implements at its discretion, then use it. If something feels off, give detailed instructions, Claude fixes it, and you use it again. Repeat as needed. At a stopping point, say &amp;quot;Document this and commit.&amp;quot; Claude documents and commits the work, and you move on to the next feature." width="800" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In August, when Claude interviewed me to help put this approach into words, I said:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For a feature being implemented for the first time, I gave only the broad strokes. For changes to existing features, I was specific.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The principle was the same whether the decision was about an algorithm, the look of the UI, or what to document. I didn't change how much I delegated based on the kind of decision. I applied the same rule everywhere: delegate first, then give detailed instructions if something feels wrong in use.&lt;/p&gt;

&lt;p&gt;Let's go through each stage of the loop with real examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  Delegating the broad strokes
&lt;/h2&gt;

&lt;p&gt;On the day I started JSInterpreter, this was my entire first instruction about step execution:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It shall provide an API for step execution (step in, step out, step over, step back).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It says nothing about how to implement it. When I'm exploring, I find it faster to see a proposal first and then decide than to write a complete specification up front. (I have also started a project by pinning down the requirements first. I'll cover that in the next post.) I left much of the algorithm selection and UI layout to Claude as well.&lt;/p&gt;

&lt;p&gt;As a result, to be honest, &lt;strong&gt;I don't know everything that's in the tool I built&lt;/strong&gt;. On June 14, I asked this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I don't see how useful the information in the Timeline and Bar Chart tabs is. When would you use them?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I quickly corrected myself: "I meant Lifetime, not Timeline." I had confused the names of tabs in my own tool. At the time, Lifetime was a chart of horizontal bars showing how long each variable existed. Claude reread the source, explained how to use it, and even added a table comparing it with other views, but I still didn't find it useful because its role overlapped with theirs.&lt;/p&gt;

&lt;p&gt;Two days later, Lifetime was rebuilt as a stack of horizontal bars showing when each function call started and ended, what's usually called a flame chart. As I remember it, my instruction was along the lines of "If you put the call stack on a timeline, you get this, right?" That is the version in the tool today, and I use it in class.&lt;/p&gt;

&lt;p&gt;What I learned is that &lt;strong&gt;asking the AI "What is this feature for?" can itself reveal that something is wrong&lt;/strong&gt;. If the explanation doesn't convince you, that's a signal worth acting on.&lt;/p&gt;

&lt;h2&gt;
  
  
  You can reject a plan before any code exists
&lt;/h2&gt;

&lt;p&gt;Back to the step execution API. Claude asked one question about the intended use and then presented its first plan. The interpreter would be built with generators and pause at each statement boundary. To step back, it would rerun the program from the start and stop one step earlier.&lt;/p&gt;

&lt;p&gt;I rejected the plan. Not one line of code had been written yet. In Claude Code's plan mode, you're asked whether to proceed with the plan, and I simply said no.&lt;/p&gt;

&lt;p&gt;Then I wrote out the approach I had in mind:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Here is how I'm thinking about step execution. First, step through the program. Store the state at every step. For step execution, retrieve the appropriate state according to the type of step: step in, step over, step out, or step back. Is this implementation reasonable?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude withdrew its plan and adopted mine:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Compared with my original proposal (generators plus replay), &lt;strong&gt;the implementation is more intuitive and simpler&lt;/strong&gt;. In particular, making stepBack O(1) is a major advantage.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My point is that &lt;strong&gt;the "use it" in "use it and notice something off" doesn't only happen after you've touched working software&lt;/strong&gt;. If you read a plan and think "this isn't right," you can stop there and offer your own idea. That is far cheaper than fixing things after the code is written.&lt;/p&gt;

&lt;h2&gt;
  
  
  You don't need to know the name of the technique
&lt;/h2&gt;

&lt;p&gt;My proposal above doesn't name a technique. Claude's reply began like this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is a very good design. This approach corresponds to a technique called &lt;strong&gt;omniscient debugging&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My reaction at the time was "What's omniscient debugging?" But I didn't ask. I decided to look it up later and immediately moved on to my next request:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Please revise the plan. I'd also like finer granularity (higher resolution). I want to be able to execute, or rather evaluate, by expression, not just by statement.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I learned something new and got what I wanted, which helped a lot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To give detailed instructions, you don't need to know the names of techniques or algorithms.&lt;/strong&gt; If you describe what you want specifically in your own words, the AI can map it to an existing concept and tell you its name. The Lifetime instruction above works the same way. I never said "flame chart." I just combined two terms I knew, "call stack" and "timeline."&lt;/p&gt;

&lt;p&gt;What matters more than the name is thinking concretely about what you want and writing it down. When that's hard, you can ask the AI questions to sort out your thinking. Keep in mind, though, that the names and explanations an AI gives you aren't always correct. I didn't stop at hearing the name; I looked it up afterward.&lt;/p&gt;

&lt;p&gt;This "record the state of every step" approach became the foundation of JSVisualizer. It's why you can move freely forward and backward through the steps (&lt;a href="https://github.com/tntetsu/JSVisualizer/blob/main/docs/adr/ADR-001-omniscient-debugging.md" rel="noopener noreferrer"&gt;ADR-001&lt;/a&gt;, in Japanese, like the other ADRs linked here). It comes at a cost: because every step is recorded up front, programs that exceed the limit (50,000 steps as of November 2026) are cut off partway. That was acceptable because the tool targets small educational programs.&lt;/p&gt;

&lt;h2&gt;
  
  
  When something feels wrong, give detailed instructions
&lt;/h2&gt;

&lt;p&gt;This is the heart of the loop. What does "detailed instructions" actually mean? Here are three recent examples from October.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The symptom and the desired result&lt;/strong&gt; (call tree appearance, &lt;a href="https://github.com/tntetsu/JSVisualizer/blob/main/docs/adr/ADR-045-compact-calltree-nodes.md" rel="noopener noreferrer"&gt;ADR-045&lt;/a&gt;)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the call tree, I want the arguments next to the function name, not on the line below it. I also want the display to be more compact. There's a lot of empty space inside the call boxes, so please reduce the margins on all sides and make the boxes smaller.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;"A lot of empty space" is the symptom. "Next to the function name" and "smaller boxes" are the desired result. I didn't specify any pixel values. Claude reduced the node height from 80px to 34px and made the width fit the text.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. What feels wrong, a proposal, a request for an opinion, and the scope&lt;/strong&gt; (tab name)&lt;/p&gt;

&lt;p&gt;The Japanese name of one tab used the word for "assignment," although the view has nothing to do with assignment in JavaScript. It shows function calls being replaced with their values (the substitution model).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;That Japanese term is a strange translation of "substitute." I think the tab should be renamed to the word for "substitution." What do you think? If that's OK, please fix it everywhere, in the tool's display and all the documentation.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The name had been there since the view was added in June. For four and a half months, nobody, including me, said it was odd. It finally bothered me once the tool was in use in class. I asked "What do you think?" because my idea might not be right. The last sentence sets the scope: not just the screen, but all the documentation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Adding the reason&lt;/strong&gt; (the sample on the initial screen)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the fib sample on JSVisualizer's initial screen, the if condition is n &amp;lt;= 1. Please change it to n == 1 || n == 2. My course materials use this form. If the condition differs, the number of function calls differs too, which is likely to confuse students.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When you include the reason, Claude can make judgments beyond the instruction itself. In this case, Claude decided on its own to leave another sample with the same condition unchanged, and it told me why: the sample came from an earlier evaluation experiment, so changing it would make things inconsistent with the experiment's results.&lt;/p&gt;

&lt;p&gt;To sum up, my detailed instructions included &lt;strong&gt;what's wrong (the symptom)&lt;/strong&gt;, &lt;strong&gt;what I want (the desired result)&lt;/strong&gt;, and &lt;strong&gt;why (the reason)&lt;/strong&gt;. In most cases, they didn't say how to implement it.&lt;/p&gt;

&lt;h3&gt;
  
  
  You don't have to get it right the first time
&lt;/h3&gt;

&lt;p&gt;Some things took many rounds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The view that shows variables changing in a table went from two panes to one, back to two, and finally to one again. Two panes duplicated the code display on the left, narrowed the table, and required complicated scroll syncing (&lt;a href="https://github.com/tntetsu/JSVisualizer/blob/main/docs/adr/ADR-012-linetrace-single-pane.md" rel="noopener noreferrer"&gt;ADR-012&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;The view that draws object references started with a force-directed layout. It worked, but it left a lot of empty space, and arrows of the same kind pointed in different directions each time, so you couldn't read the shape of the data structure. I replaced it with a hierarchical layout (&lt;a href="https://github.com/tntetsu/JSVisualizer/blob/main/docs/adr/ADR-021-objectgraph-hierarchical-layout.md" rel="noopener noreferrer"&gt;ADR-021&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There were also plenty of small fixes that never became ADRs. As of August 9, about 20 of the 103 commits started with "fix:".&lt;/p&gt;

&lt;h3&gt;
  
  
  When I reverted Claude's fix
&lt;/h3&gt;

&lt;p&gt;Sometimes Claude changed the whole approach in response to a bug report. On May 24, I reported this about JSInterpreter's web page:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I tested it, but the samples don't work. When I choose a program from the samples, it doesn't appear in the editor.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude concluded that the cause was my opening the file directly. As a "root fix," it changed the bundle format from ES modules to an IIFE and committed the change, so the page would work when opened directly. All 185 tests passed.&lt;/p&gt;

&lt;p&gt;But that wasn't the direction I wanted, so I had it reverted with this instruction:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Still, I want to go with ESM. Requiring an HTTP server is fine.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Passing tests won't reveal this kind of difference in judgment. You need to check not only whether a bug was fixed, but also how. Since I don't read the code, my clue was Claude's report.&lt;/p&gt;

&lt;h2&gt;
  
  
  At a stopping point: "Document this and commit"
&lt;/h2&gt;

&lt;p&gt;At a stopping point, all I said was "Document this and commit." Claude decided what went into CLAUDE.md and what became a separate ADR.&lt;/p&gt;

&lt;p&gt;That means I had delegated the editorial decision of what to record, the last step of the loop, just as I had delegated implementation decisions. I'll discuss whether that was a good idea in part 3.&lt;/p&gt;

&lt;h2&gt;
  
  
  The limits of this approach
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;My software experience helped in places.&lt;/strong&gt; It's why I could propose the step execution approach myself. At the same time, when my memory was uncertain, I asked Claude, as with "Please explain the contents of package.json line by line in detail." I think being able to ask about what you don't know as you go helps, however much experience you have.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I haven't verified test coverage.&lt;/strong&gt; Bugs have often surfaced later, and I expect more will. Even so, I consider the tool good enough to use in class.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You only notice what feels wrong when someone looks at it.&lt;/strong&gt; That odd tab name stayed for four and a half months. Problems on screens I don't look at go unnoticed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;I don't know everything about what I delegated.&lt;/strong&gt; As with Lifetime, I sometimes learn what a feature is for only by asking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Some session logs no longer exist.&lt;/strong&gt; I checked the timeline against session logs and git history, but the wording of my instruction for rebuilding Lifetime is from memory. I'll explain why the logs disappeared in part 5.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] When exploring a feature, give only the broad requirements and let the AI implement them. Don't try to write a perfect specification up front.&lt;/li&gt;
&lt;li&gt;[ ] If a plan looks wrong, reject it on the spot and offer your own idea.&lt;/li&gt;
&lt;li&gt;[ ] Use the implementation, and write down what feels wrong or unsatisfying.&lt;/li&gt;
&lt;li&gt;[ ] If you don't know what a feature is for, ask the AI to explain it. If the answer doesn't convince you, treat that as something wrong too.&lt;/li&gt;
&lt;li&gt;[ ] When giving new instructions, include the symptom, the desired result, and the reason. You don't need to know the names of techniques.&lt;/li&gt;
&lt;li&gt;[ ] Look up the names and explanations the AI gives you to confirm them.&lt;/li&gt;
&lt;li&gt;[ ] Check behavior by using the software yourself, and ask for tests too. Don't assume that passing tests means full coverage.&lt;/li&gt;
&lt;li&gt;[ ] For bug fixes, read the report to check not only that the bug was fixed, but how.&lt;/li&gt;
&lt;li&gt;[ ] At a stopping point, explicitly ask the AI to document the work and commit.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Next time
&lt;/h2&gt;

&lt;p&gt;This post was about the loop, but the first thing that stumped me when I started was "What should I do first?" For JSInterpreter, I ran &lt;code&gt;/init&lt;/code&gt; in an empty directory and answered Claude's questions.&lt;/p&gt;

&lt;p&gt;Next time: "The first step was CLAUDE.md." I'll cover how to start CLAUDE.md both from an empty directory and with existing code, and how it changed over time.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Models changed over this period. The JSInterpreter exchanges in this post (May 2026) used Claude Sonnet 4.6, and the October examples used Claude Opus 5.5.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claudecode</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>Which Branch Did My if Take? Seeing if / else if as a Flowchart</title>
      <dc:creator>Tetsuo TANAKA</dc:creator>
      <pubDate>Fri, 06 Nov 2026 00:45:45 +0000</pubDate>
      <link>https://dev.to/tntetsu/which-branch-did-my-if-take-seeing-if-else-if-as-a-flowchart-14d8</link>
      <guid>https://dev.to/tntetsu/which-branch-did-my-if-take-seeing-if-else-if-as-a-flowchart-14d8</guid>
      <description>&lt;p&gt;In this series, we use &lt;a href="https://tntetsu.github.io/JSVisualizer/" rel="noopener noreferrer"&gt;JSVisualizer&lt;/a&gt;, a free browser-based tool, to understand classic algorithms by &lt;em&gt;watching&lt;/em&gt; them run. The first post gave a tour of the tool, and the second looked at &lt;code&gt;for&lt;/code&gt; loops.&lt;/p&gt;

&lt;p&gt;This time the topic is &lt;strong&gt;conditionals&lt;/strong&gt; — &lt;code&gt;if&lt;/code&gt;, &lt;code&gt;else if&lt;/code&gt;, and &lt;code&gt;else&lt;/code&gt;. The star of the show is the &lt;strong&gt;Control Flow&lt;/strong&gt; view.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where beginners get stuck
&lt;/h2&gt;

&lt;p&gt;This program turns a &lt;code&gt;score&lt;/code&gt; into a letter &lt;code&gt;grade&lt;/code&gt;: 80 or above is an A, 60 or above is a B, and anything lower is a C.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;72&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;grade&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;grade&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"A"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;grade&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"B"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;grade&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"C"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grade&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It prints B. Short as it is, people who've just learned conditionals often wonder:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;When is the &lt;code&gt;else if&lt;/code&gt; checked?&lt;/strong&gt; 72 is "60 or above", so it's a B. But was the "80 or above" condition checked too? Did the code inside the final &lt;code&gt;else&lt;/code&gt; run?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Does the order of the conditions matter?&lt;/strong&gt; What happens if you swap &lt;code&gt;score &amp;gt;= 80&lt;/code&gt; and &lt;code&gt;score &amp;gt;= 60&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Checking which branch ran is tedious.&lt;/strong&gt; Plenty of us have sprinkled &lt;code&gt;console.log("got here")&lt;/code&gt; into every block just to find out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JSVisualizer's Control Flow view &lt;strong&gt;turns your branches into a flowchart and shows, in different colors, the paths the program actually took and the ones it didn't&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seeing it in the Control Flow view
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How to read it
&lt;/h3&gt;

&lt;p&gt;Paste the code into JSVisualizer, press &lt;strong&gt;▶ Run&lt;/strong&gt;, and open the &lt;strong&gt;Control Flow&lt;/strong&gt; tab. Then press &lt;strong&gt;▷ Human&lt;/strong&gt; (one "human-friendly" step) twice. You'll see 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%2Fefnb78n14bfmd5a3biwi.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%2Fefnb78n14bfmd5a3biwi.png" alt="Control Flow view: the if's true column holds grade = &amp;quot;A&amp;quot; (grayed out); its false column holds the else if, whose true column holds grade = &amp;quot;B&amp;quot; (×1) and whose false column holds grade = &amp;quot;C&amp;quot; (grayed out)" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rows marked with ◇&lt;/strong&gt; are conditions. Below each one, the flow splits: the left column is the &lt;strong&gt;true&lt;/strong&gt; path (the condition held), and the right column is the &lt;strong&gt;false&lt;/strong&gt; path (it didn't).&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;else if&lt;/code&gt; sits &lt;strong&gt;inside the false side&lt;/strong&gt; of the first &lt;code&gt;if&lt;/code&gt;. "If it's not 80 or above, then check whether it's 60 or above" — that nesting is drawn right there in the shape.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;×1&lt;/strong&gt; on each row is how many times that row ran.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gray, dashed boxes&lt;/strong&gt; are rows that &lt;strong&gt;never ran&lt;/strong&gt; in this run. Here, &lt;code&gt;grade = "A"&lt;/code&gt; and &lt;code&gt;grade = "C"&lt;/code&gt; are gray.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The blue outline&lt;/strong&gt; marks the row being executed right now (here, line 2, &lt;code&gt;let grade;&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We're still on line 2, yet &lt;code&gt;grade = "B"&lt;/code&gt; already shows ×1, and A and C are already gray. The Control Flow view shows you &lt;strong&gt;which paths the whole run takes, and how many times&lt;/strong&gt;, right from the start. As you step forward, the blue outline follows that path to show where you are.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stepping forward
&lt;/h3&gt;

&lt;p&gt;Press &lt;strong&gt;▷ Human&lt;/strong&gt; three more times (five in total):&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%2F0g2cyrhwyjra994ospjy.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%2F0g2cyrhwyjra994ospjy.png" alt="Control Flow view: the blue outline has reached grade = &amp;quot;B&amp;quot; on the true side of the else if" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The blue outline has moved from &lt;code&gt;if (score &amp;gt;= 80)&lt;/code&gt; to &lt;code&gt;else if (score &amp;gt;= 60)&lt;/code&gt; to &lt;code&gt;grade = "B"&lt;/code&gt;. A score of 72 isn't 80 or above, so the first &lt;code&gt;if&lt;/code&gt; sends execution down the false path, and the &lt;code&gt;else if&lt;/code&gt; then sends it down the true path.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the flowchart reveals
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. An &lt;code&gt;else if&lt;/code&gt; is checked only when the conditions before it are false
&lt;/h3&gt;

&lt;p&gt;In the flowchart, the &lt;code&gt;else if&lt;/code&gt; lives inside the false side of the first &lt;code&gt;if&lt;/code&gt;. That means &lt;code&gt;else if (score &amp;gt;= 60)&lt;/code&gt; is checked &lt;strong&gt;only when &lt;code&gt;score &amp;gt;= 80&lt;/code&gt; turned out false&lt;/strong&gt;. An &lt;code&gt;if&lt;/code&gt; / &lt;code&gt;else if&lt;/code&gt; / &lt;code&gt;else&lt;/code&gt; chain checks its conditions from the top down and runs &lt;strong&gt;only the block for the first condition that's true&lt;/strong&gt;. If every condition is false, the final &lt;code&gt;else&lt;/code&gt; block runs. Without an &lt;code&gt;else&lt;/code&gt;, it's possible for no block to run at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Put conditions in the wrong order, and some paths become unreachable
&lt;/h3&gt;

&lt;p&gt;Let's swap the conditions and try a score of 95:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;grade&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;grade&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"B"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;grade&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"A"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;grade&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"C"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grade&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;A score of 95 comes out as a B. The Control Flow view shows why:&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%2Fjbxhdcwsd4cyz6qlb89q.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%2Fjbxhdcwsd4cyz6qlb89q.png" alt="Letter grade with conditions in the wrong order: only grade = &amp;quot;B&amp;quot; under if (score &gt;= 60) has ×1; the else if (score &gt;= 80) row itself, grade = &amp;quot;A&amp;quot;, and grade = &amp;quot;C&amp;quot; are all gray" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not only is &lt;code&gt;grade = "A"&lt;/code&gt; gray — &lt;strong&gt;the &lt;code&gt;else if (score &amp;gt;= 80)&lt;/code&gt; row itself is gray&lt;/strong&gt;. Since 95 already passes the first test, &lt;code&gt;score &amp;gt;= 60&lt;/code&gt;, the &lt;code&gt;score &amp;gt;= 80&lt;/code&gt; condition &lt;strong&gt;is never even checked&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In fact, this program can never produce an A, whatever the score. Every score of 60 or above is caught by the first &lt;code&gt;if&lt;/code&gt;, and anything below 60 isn't 80 or above either. Run it a few times with different scores and you'll see &lt;code&gt;grade = "A"&lt;/code&gt; stay gray every time.&lt;/p&gt;

&lt;p&gt;Every score of 80 or above is also 60 or above. &lt;strong&gt;When one condition is contained in another like this, you have to check the narrower one first.&lt;/strong&gt; Which condition you check first changes which code runs.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Inside a loop, count the visits
&lt;/h3&gt;

&lt;p&gt;When a conditional sits inside a loop, the ×N counts start to tell a story. Here's the classic FizzBuzz: print the numbers 1 to 15, but print Fizz for multiples of 3, Buzz for multiples of 5, and FizzBuzz for multiples of both.&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="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"FizzBuzz"&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;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Fizz"&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;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Buzz"&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;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A number that's a multiple of both 3 and 5 is a multiple of 15, so the code checks &lt;code&gt;i % 15 === 0&lt;/code&gt; first. &lt;code&gt;%&lt;/code&gt; gives the remainder of a division, so a remainder of 0 means the number divides evenly. &lt;code&gt;===&lt;/code&gt; checks whether the two sides are equal.&lt;/p&gt;

&lt;p&gt;Run it to the end and you'll see the following. (When &lt;code&gt;else if&lt;/code&gt; chains nest deeply, the flowchart may run past the right edge; just scroll sideways to see the rest.)&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%2F0xl37soszebw6idmiu5l.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%2F0xl37soszebw6idmiu5l.png" alt="FizzBuzz control flow: for ×16, if (i % 15 === 0) ×15, FizzBuzz ×1, else if (i % 3 === 0) ×14, Fizz ×4, else if (i % 5 === 0) ×10, Buzz ×2, console.log(i) ×8" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Out of 1–15: FizzBuzz once (15), Fizz 4 times (3, 6, 9, 12), Buzz twice (5, 10), and the plain number 8 times — 15 in total.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;else if (i % 3 === 0)&lt;/code&gt; ran ×14 and &lt;code&gt;else if (i % 5 === 0)&lt;/code&gt; ran ×10. The numbers confirm that each one is checked only as many times as the conditions before it were false.&lt;/li&gt;
&lt;li&gt;For a &lt;code&gt;for&lt;/code&gt; row, the Control Flow view counts how many times the condition was checked. It shows ×16 because the condition &lt;code&gt;i &amp;lt;= 15&lt;/code&gt; was true 15 times and then false on the 16th check, which ended the loop. (It's the same "the loop variable goes one step past the end" effect we saw in the previous post.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The lesson from point 2 applies here too: written this way, multiples of 15 are also multiples of 3 and of 5, so &lt;code&gt;i % 15 === 0&lt;/code&gt; has to be checked first. See what happens when you change the order in the exercises below.&lt;/p&gt;

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

&lt;p&gt;Open the link below and press &lt;strong&gt;▶ Run&lt;/strong&gt;; the Control Flow view opens. Step forward with &lt;strong&gt;▷ Human&lt;/strong&gt; (the &lt;code&gt;h&lt;/code&gt; key) and back with &lt;strong&gt;◁ Human&lt;/strong&gt; (&lt;code&gt;H&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://tntetsu.github.io/JSVisualizer/?code=https%3A%2F%2Ftntetsu.github.io%2FJSVisualizer%2Fsamples%2Farticles%2F02-grade.en.json&amp;amp;view=controlflow" rel="noopener noreferrer"&gt;▶ Open in JSVisualizer (letter grade, Control Flow view)&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To change the code, press &lt;strong&gt;✏ Edit&lt;/strong&gt;. Before each run, &lt;strong&gt;predict&lt;/strong&gt; which rows will be gray:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set &lt;code&gt;score&lt;/code&gt; to 85, or to 40. Which path does it take?&lt;/li&gt;
&lt;li&gt;Delete the final &lt;code&gt;else { grade = "C"; }&lt;/code&gt;. What is &lt;code&gt;grade&lt;/code&gt; when the score is 40?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two more programs to play with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://tntetsu.github.io/JSVisualizer/?code=https%3A%2F%2Ftntetsu.github.io%2FJSVisualizer%2Fsamples%2Farticles%2F02-grade-bug.en.json&amp;amp;view=controlflow" rel="noopener noreferrer"&gt;▶ Letter grade with conditions in the wrong order&lt;/a&gt;&lt;/strong&gt;: try lots of scores. Is there any score that gets an A?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://tntetsu.github.io/JSVisualizer/?code=https%3A%2F%2Ftntetsu.github.io%2FJSVisualizer%2Fsamples%2Farticles%2F02-fizzbuzz.en.json&amp;amp;view=controlflow" rel="noopener noreferrer"&gt;▶ FizzBuzz&lt;/a&gt;&lt;/strong&gt;: move the &lt;code&gt;i % 15 === 0&lt;/code&gt; branch after the &lt;code&gt;i % 3 === 0&lt;/code&gt; one. How many times does &lt;code&gt;console.log("FizzBuzz")&lt;/code&gt; run now?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The Control Flow view draws your branches as a flowchart and shows &lt;strong&gt;which paths the whole run took, and how many times&lt;/strong&gt;. Paths that never ran are grayed out.&lt;/li&gt;
&lt;li&gt;An &lt;code&gt;else if&lt;/code&gt; lives on the false side of the condition before it. Conditions are checked from the top, and only the block for the first true condition runs.&lt;/li&gt;
&lt;li&gt;When one condition is contained in another, putting them in the wrong order gives you paths that never run (they stay gray). For branches inside a loop, the ×N counts let you check the numbers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Next up:&lt;/strong&gt; &lt;strong&gt;functions&lt;/strong&gt;. We'll use the &lt;strong&gt;Call Stack&lt;/strong&gt; view to see what actually happens when you call a function, and why two variables with the same name don't clash.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>education</category>
      <category>visualization</category>
    </item>
    <item>
      <title>Watch a for Loop Change Your Variables, One Step at a Time</title>
      <dc:creator>Tetsuo TANAKA</dc:creator>
      <pubDate>Fri, 30 Oct 2026 09:28:55 +0000</pubDate>
      <link>https://dev.to/tntetsu/watch-a-for-loop-change-your-variables-one-step-at-a-time-5co1</link>
      <guid>https://dev.to/tntetsu/watch-a-for-loop-change-your-variables-one-step-at-a-time-5co1</guid>
      <description>&lt;p&gt;In this series, we use &lt;a href="https://tntetsu.github.io/JSVisualizer/" rel="noopener noreferrer"&gt;JSVisualizer&lt;/a&gt;, a free browser-based tool, to understand classic algorithms by &lt;em&gt;watching&lt;/em&gt; them run. (New here? The previous post gives a quick tour of the tool.)&lt;/p&gt;

&lt;p&gt;This time the topic is the &lt;strong&gt;&lt;code&gt;for&lt;/code&gt; loop&lt;/strong&gt; and the &lt;strong&gt;running total&lt;/strong&gt;: adding numbers up one at a time. The star of the show is the &lt;strong&gt;Variable&lt;/strong&gt; view.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where beginners get stuck
&lt;/h2&gt;

&lt;p&gt;Here's a program that adds up the numbers from 1 to 5:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It prints 15. Simple enough — and yet beginners often trip up on a few things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;sum = sum + i&lt;/code&gt; looks wrong.&lt;/strong&gt; In math, "sum equals sum plus i" is nonsense. In code, &lt;code&gt;=&lt;/code&gt; means "compute the right-hand side, then store the result in the variable on the left" — this is called &lt;strong&gt;assignment&lt;/strong&gt;. Knowing that is one thing; actually feeling it is another.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In what order do the three parts of &lt;code&gt;for (...; ...; ...)&lt;/code&gt; run?&lt;/strong&gt; When does &lt;code&gt;i++&lt;/code&gt; happen? When is &lt;code&gt;i &amp;lt;= 5&lt;/code&gt; checked?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What is &lt;code&gt;i&lt;/code&gt; when the loop ends?&lt;/strong&gt; It loops five times, so… 5?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Teachers often have students answer questions like these with a &lt;strong&gt;trace table&lt;/strong&gt;: a hand-drawn table where you add a row for each step as the program runs, writing down the line number and the value of each variable. It's a great way to understand how a program behaves, but the more a loop repeats, the more there is to write, and one slip of the pencil can leave you more confused than before.&lt;/p&gt;

&lt;p&gt;JSVisualizer's Variable view serves the same purpose as a trace table: &lt;strong&gt;following how variable values change&lt;/strong&gt;. But instead of adding a row for each step, it &lt;strong&gt;shows, next to each line of the source code, the values the variables had the last time that line ran&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seeing it in the Variable view
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How to read it
&lt;/h3&gt;

&lt;p&gt;Paste the code into JSVisualizer, press &lt;strong&gt;▶ Run&lt;/strong&gt;, and open the &lt;strong&gt;Variable&lt;/strong&gt; tab. Then press &lt;strong&gt;▷ Human&lt;/strong&gt; three times. (A "human-friendly" step stops only at meaningful changes, such as assignments and condition checks.) You'll see 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%2Ffhqgaeff9fl1p3nen6ix.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%2Ffhqgaeff9fl1p3nen6ix.png" alt="Variable view: on line 2, sum = 0, i = 1, and i &lt;= 5 is true" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rows&lt;/strong&gt; are the lines of your source code. The line being executed (here, line 2, the &lt;code&gt;for&lt;/code&gt;) is highlighted in blue.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Columns&lt;/strong&gt; are the variables in your program (&lt;code&gt;sum&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt;). A new column appears when a variable is created.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The rightmost column&lt;/strong&gt; shows the result of the loop condition, &lt;code&gt;i &amp;lt;= 5&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Each cell&lt;/strong&gt; holds &lt;strong&gt;the variable's value the last time that line ran&lt;/strong&gt;. Lines that haven't run yet show "—".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At a glance: line 1 set &lt;code&gt;sum&lt;/code&gt; to 0, line 2 set &lt;code&gt;i&lt;/code&gt; to 1, and the condition &lt;code&gt;i &amp;lt;= 5&lt;/code&gt; came out &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stepping forward
&lt;/h3&gt;

&lt;p&gt;Press &lt;strong&gt;▷ Human&lt;/strong&gt; five more times (eight in total):&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%2Fezusdjjjjcxbit5vqsgu.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%2Fezusdjjjjcxbit5vqsgu.png" alt="Variable view: line 2 shows sum = 3 and i = 3 (the changed i is orange); line 3 shows sum = 3 and i = 2" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On line 2, &lt;code&gt;i&lt;/code&gt; is now &lt;strong&gt;3&lt;/strong&gt;, highlighted in orange. Orange means &lt;strong&gt;"this value changed on this step."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now look at line 3. There, &lt;code&gt;i&lt;/code&gt; is still &lt;strong&gt;2&lt;/strong&gt;. That tells you the last time line 3 (&lt;code&gt;sum = sum + i&lt;/code&gt;) ran, &lt;code&gt;i&lt;/code&gt; was 2, and &lt;code&gt;sum&lt;/code&gt; became 1 + 2 = 3. After that, execution went back to line 2, ran &lt;code&gt;i++&lt;/code&gt;, and &lt;code&gt;i&lt;/code&gt; became 3. &lt;strong&gt;The same variable can show a different value on different rows&lt;/strong&gt;, and that difference tells you the order in which things happened.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running to the end
&lt;/h3&gt;

&lt;p&gt;Jump to the end (the &lt;code&gt;End&lt;/code&gt; key on your keyboard does this in one go):&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%2F72tjct0gkkf32mb8s7l0.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%2F72tjct0gkkf32mb8s7l0.png" alt="Variable view: line 2 shows sum = 15, i = 6, and i &lt;= 5 is false; line 3 shows sum = 15, i = 5; line 5 shows sum = 15 and i as —" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The console at the bottom prints 15. The total is correct — but the table tells you more than that.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the table reveals
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. &lt;code&gt;i++&lt;/code&gt; runs &lt;em&gt;after&lt;/em&gt; the loop body
&lt;/h3&gt;

&lt;p&gt;As you step through, compare lines 2 and 3: right after &lt;code&gt;i++&lt;/code&gt; runs, the &lt;code&gt;i&lt;/code&gt; on line 3 is one less than the &lt;code&gt;i&lt;/code&gt; on line 2. That's because a &lt;code&gt;for&lt;/code&gt; loop runs in this order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;let i = 1&lt;/code&gt; (once, at the very start)&lt;/li&gt;
&lt;li&gt;Check &lt;code&gt;i &amp;lt;= 5&lt;/code&gt; → if &lt;code&gt;true&lt;/code&gt;, run the body; if &lt;code&gt;false&lt;/code&gt;, leave the loop&lt;/li&gt;
&lt;li&gt;Run the body: &lt;code&gt;sum = sum + i&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;i++&lt;/code&gt;, then go back to step 2&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;i++&lt;/code&gt; is written at the far right of the &lt;code&gt;for&lt;/code&gt; line, but &lt;strong&gt;it runs after the body&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The loop exits when &lt;code&gt;i&lt;/code&gt; reaches 6
&lt;/h3&gt;

&lt;p&gt;In the final table, line 2 shows &lt;code&gt;i&lt;/code&gt; as &lt;strong&gt;6&lt;/strong&gt; and the condition &lt;code&gt;i &amp;lt;= 5&lt;/code&gt; as &lt;strong&gt;false&lt;/strong&gt;. Line 3, meanwhile, shows &lt;code&gt;i&lt;/code&gt; as &lt;strong&gt;5&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The body runs five times, for &lt;code&gt;i&lt;/code&gt; = 1, 2, 3, 4, and 5. But &lt;code&gt;i&lt;/code&gt; itself goes up to 6, and &lt;strong&gt;the loop ends &lt;em&gt;because&lt;/em&gt; &lt;code&gt;i&lt;/code&gt; reached 6 and the condition became &lt;code&gt;false&lt;/code&gt;&lt;/strong&gt;. Keep this picture in mind for the classic quiz question: "What changes if you write &lt;code&gt;i &amp;lt; 5&lt;/code&gt; instead of &lt;code&gt;i &amp;lt;= 5&lt;/code&gt;?"&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Outside the loop, &lt;code&gt;i&lt;/code&gt; doesn't exist
&lt;/h3&gt;

&lt;p&gt;On line 5, &lt;code&gt;console.log(sum)&lt;/code&gt;, the &lt;code&gt;i&lt;/code&gt; column shows "—". A variable declared with &lt;code&gt;let&lt;/code&gt; in &lt;code&gt;for (let i = 1; ...)&lt;/code&gt; &lt;strong&gt;can only be used inside the loop&lt;/strong&gt;, so code outside the loop can't refer to it. The region where a variable can be used is called its &lt;strong&gt;scope&lt;/strong&gt;. Try changing line 5 to &lt;code&gt;console.log(i)&lt;/code&gt;: a &lt;strong&gt;Runtime Error&lt;/strong&gt; appears below the code, saying &lt;code&gt;'i' is not defined&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. &lt;code&gt;sum = sum + i&lt;/code&gt; means "replace"
&lt;/h3&gt;

&lt;p&gt;On line 3, &lt;code&gt;sum&lt;/code&gt; is overwritten with every pass: 1 → 3 → 6 → 10 → 15. Watching the old value get replaced makes it click that &lt;code&gt;=&lt;/code&gt; doesn't mean "equals". It means "compute the right side and put the result back into the variable on the left."&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: see the full history with Exec Trace
&lt;/h2&gt;

&lt;p&gt;The Variable view shows &lt;strong&gt;the latest value for each line&lt;/strong&gt;, so the table stays exactly as tall as your code and is easy to compare against it. The trade-off is that older values get overwritten.&lt;/p&gt;

&lt;p&gt;When you want to see &lt;strong&gt;the values at every single step, in order&lt;/strong&gt;, switch to the &lt;strong&gt;Exec Trace&lt;/strong&gt; tab. It's essentially the complete hand-written trace table:&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%2Foa0yia56mcjeasoe71k1.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%2Foa0yia56mcjeasoe71k1.png" alt="Exec Trace view: 19 steps listed top to bottom with the values of sum, i, and the loop condition" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reading top to bottom, you can follow the whole story in one pass: &lt;code&gt;sum&lt;/code&gt; grows 0 → 1 → 3 → 6 → 10 → 15, and finally &lt;code&gt;i&lt;/code&gt; hits 6 and the condition turns &lt;code&gt;false&lt;/code&gt;. Exec Trace gets its own post later in the series, when we look at binary search.&lt;/p&gt;

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

&lt;p&gt;Open the link below and press &lt;strong&gt;▶ Run&lt;/strong&gt;; the Variable view opens. Step forward with &lt;strong&gt;▷ Human&lt;/strong&gt; (the &lt;code&gt;h&lt;/code&gt; key) and back with &lt;strong&gt;◁ Human&lt;/strong&gt; (&lt;code&gt;H&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://tntetsu.github.io/JSVisualizer/?code=https%3A%2F%2Ftntetsu.github.io%2FJSVisualizer%2Fsamples%2Farticles%2F01-loop-sum.en.json&amp;amp;view=trace" rel="noopener noreferrer"&gt;▶ Open in JSVisualizer (sum of 1 to 5, Variable view)&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To change the code, press &lt;strong&gt;✏ Edit&lt;/strong&gt;. Try these edits — and &lt;strong&gt;predict&lt;/strong&gt; how the table will change before you run each one:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change &lt;code&gt;i &amp;lt;= 5&lt;/code&gt; to &lt;code&gt;i &amp;lt; 5&lt;/code&gt;. What's the total? What is &lt;code&gt;i&lt;/code&gt; when the loop exits?&lt;/li&gt;
&lt;li&gt;Change &lt;code&gt;i++&lt;/code&gt; to &lt;code&gt;i += 2&lt;/code&gt;. Which numbers get added?&lt;/li&gt;
&lt;li&gt;Change &lt;code&gt;sum = sum + i&lt;/code&gt; to &lt;code&gt;sum = sum * i&lt;/code&gt;, and start &lt;code&gt;sum&lt;/code&gt; at &lt;code&gt;1&lt;/code&gt;. What does the program compute now?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The Variable view puts each line of your code next to the values its variables had the last time that line ran. Like a trace table, it lets you follow how values change.&lt;/li&gt;
&lt;li&gt;Values that just changed are highlighted in orange, so you can see what each step did.&lt;/li&gt;
&lt;li&gt;Comparing rows reveals how a &lt;code&gt;for&lt;/code&gt; loop really runs (check → body → &lt;code&gt;i++&lt;/code&gt;) and even what &lt;code&gt;i&lt;/code&gt; is when the loop exits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Next up:&lt;/strong&gt; &lt;strong&gt;conditionals&lt;/strong&gt; (&lt;code&gt;if&lt;/code&gt; / &lt;code&gt;else if&lt;/code&gt; / &lt;code&gt;else&lt;/code&gt;). We'll run a grading program through the &lt;strong&gt;Control Flow&lt;/strong&gt; view and see, as a flowchart, which branches the program took and which it skipped.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>education</category>
      <category>visualization</category>
    </item>
    <item>
      <title>See Your JavaScript Run 12 Different Ways: Meet JSVisualizer (and How It Differs from Python Tutor)</title>
      <dc:creator>Tetsuo TANAKA</dc:creator>
      <pubDate>Fri, 30 Oct 2026 09:28:54 +0000</pubDate>
      <link>https://dev.to/tntetsu/see-your-javascript-run-12-different-ways-meet-jsvisualizer-and-how-it-differs-from-python-tutor-1kk5</link>
      <guid>https://dev.to/tntetsu/see-your-javascript-run-12-different-ways-meet-jsvisualizer-and-how-it-differs-from-python-tutor-1kk5</guid>
      <description>&lt;h2&gt;
  
  
  Why "seeing" code matters
&lt;/h2&gt;

&lt;p&gt;If you've ever learned to program — or taught someone who is — some of these will sound familiar:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You copy an example, run it, and get the right answer. But you couldn't explain &lt;em&gt;why&lt;/em&gt; it's the right answer.&lt;/li&gt;
&lt;li&gt;Recursion makes perfect sense during the lecture. Then you sit down to write a recursive function and your mind goes blank.&lt;/li&gt;
&lt;li&gt;You sprinkle &lt;code&gt;console.log&lt;/code&gt; everywhere to chase a value, and halfway through you forget what you were looking for.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The root problem is that a program's behavior is invisible. Source code is static text, but when it runs it produces &lt;strong&gt;state that changes over time&lt;/strong&gt;. Most beginner struggles come down to not being able to picture that hidden motion accurately.&lt;/p&gt;

&lt;p&gt;This series introduces &lt;strong&gt;JSVisualizer&lt;/strong&gt;, a web app that runs JavaScript one step at a time and shows you what's going on through &lt;strong&gt;12 different views&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://tntetsu.github.io/JSVisualizer/" rel="noopener noreferrer"&gt;https://tntetsu.github.io/JSVisualizer/&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It runs entirely in your browser. Nothing to install, no account needed.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The interface follows your browser's language (English, or Japanese if your browser prefers Japanese). You can switch at any time with the &lt;strong&gt;EN / 日&lt;/strong&gt; button in the top-right corner.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this first post, I'll give you a quick tour and compare JSVisualizer with the well-known &lt;strong&gt;Python Tutor&lt;/strong&gt;. From the next post on, each article picks one classic algorithm and pairs it with the view that explains it best.&lt;/p&gt;

&lt;h2&gt;
  
  
  The screen at a glance
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdgrrk85mmu0ur3o2slow.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%2Fdgrrk85mmu0ur3o2slow.png" alt="JSVisualizer: source code on the left, the Call Stack view on the right" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The screen has two halves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Left: your code.&lt;/strong&gt; Paste in any JavaScript and run it. The line being executed is highlighted in blue, and the expression being evaluated right now is highlighted in orange. When execution is inside a function, the expression that &lt;em&gt;called&lt;/em&gt; it (here, &lt;code&gt;fact(n - 1)&lt;/code&gt;) gets a dashed purple underline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Right: the views.&lt;/strong&gt; Each tab shows the &lt;em&gt;same moment&lt;/em&gt; of the &lt;em&gt;same run&lt;/em&gt; from a different angle. Above is the &lt;strong&gt;Call Stack&lt;/strong&gt; view, showing calls piling up: &lt;code&gt;fact(4)&lt;/code&gt; → &lt;code&gt;fact(3)&lt;/code&gt; → &lt;code&gt;fact(2)&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To use it, write some code, press &lt;strong&gt;▶ Run&lt;/strong&gt;, and use the buttons along the top to step forward (or backward). You can also drag the slider to jump to any point in the run.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://tntetsu.github.io/JSVisualizer/manual.en.html" rel="noopener noreferrer"&gt;user manual&lt;/a&gt; explains every button and view in detail. You can also open it with the &lt;strong&gt;?&lt;/strong&gt; button in the top-right corner.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature 1: Step at four levels of detail
&lt;/h2&gt;

&lt;p&gt;You choose how big a "step" is. Each level has its own forward and back buttons:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Buttons&lt;/th&gt;
&lt;th&gt;Unit&lt;/th&gt;
&lt;th&gt;Use it when you want to…&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;◀ Expr / ▶ Expr&lt;/td&gt;
&lt;td&gt;Expression (finest)&lt;/td&gt;
&lt;td&gt;see the order in which something like &lt;code&gt;a + b * c&lt;/code&gt; is evaluated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;◀◀ Stmt / ▶▶ Stmt&lt;/td&gt;
&lt;td&gt;Statement&lt;/td&gt;
&lt;td&gt;follow the flow one statement at a time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;◁ Human / ▷ Human&lt;/td&gt;
&lt;td&gt;"Human-friendly" step&lt;/td&gt;
&lt;td&gt;stop only at &lt;strong&gt;meaningful changes&lt;/strong&gt;: assignments, condition checks, loop updates (the best place for beginners to start)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;⏪ Func / ⏩ Func&lt;/td&gt;
&lt;td&gt;Function call&lt;/td&gt;
&lt;td&gt;skip over function bodies and watch only calls and returns&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A typical workflow: use &lt;strong&gt;Human&lt;/strong&gt; steps to get the big picture, then switch to &lt;strong&gt;Expr&lt;/strong&gt; steps when something puzzling happens. Every level can &lt;strong&gt;step backward&lt;/strong&gt;, so when you think "wait, what just happened?", you can rewind instantly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feature 2: Twelve views
&lt;/h2&gt;

&lt;p&gt;The views fall into three groups, depending on what they show:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Group&lt;/th&gt;
&lt;th&gt;What it shows&lt;/th&gt;
&lt;th&gt;Views&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;State&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;What the program remembers at a given moment&lt;/td&gt;
&lt;td&gt;Variable, Exec Trace, Call Stack, Lifetime, Memory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Behavior&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;How execution unfolds over time&lt;/td&gt;
&lt;td&gt;Expr, Subst, Control Flow, Heatmap, Call Tree&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data structures&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;What's inside arrays and objects&lt;/td&gt;
&lt;td&gt;Arrays, Objects&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Views also differ in how they handle time. Some show &lt;strong&gt;only the current moment&lt;/strong&gt; and redraw on every step (e.g. Variable, Call Stack). Others &lt;strong&gt;lay out the whole run&lt;/strong&gt; and just move your position through it (e.g. Exec Trace, Subst, Heatmap). The first kind answers "what's going on right now?"; the second answers "how did things change?"&lt;/p&gt;

&lt;p&gt;For example, here is the &lt;strong&gt;Subst&lt;/strong&gt; view (short for &lt;em&gt;substitution&lt;/em&gt;). It rewrites the recursive call &lt;code&gt;fact(4)&lt;/code&gt; the way you'd expand it by hand — &lt;code&gt;4 * fact(3)&lt;/code&gt;, then &lt;code&gt;4 * 3 * fact(2)&lt;/code&gt;, and so on — leaving the whole expansion on screen at once.&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%2Fbcrgqu4tv6qcqq8852ii.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%2Fbcrgqu4tv6qcqq8852ii.png" alt="Subst view: fact(4) expands to 4 * 3 * 2 * 1 and evaluates to 24" width="800" height="679"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Same program, same moment: the Call Stack view shows calls &lt;em&gt;stacking up&lt;/em&gt;, while the Subst view shows an &lt;em&gt;expression being rewritten&lt;/em&gt;. &lt;strong&gt;If one picture doesn't click, another one might.&lt;/strong&gt; That's the whole reason for having twelve.&lt;/p&gt;

&lt;h2&gt;
  
  
  How is this different from Python Tutor?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://pythontutor.com/" rel="noopener noreferrer"&gt;Python Tutor&lt;/a&gt; is the best-known program visualizer out there and is used by learners all over the world. Despite the name, it also supports Java, C, C++, and JavaScript. So the first question people ask about JSVisualizer is usually, "How is this different from Python Tutor?"&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;JSVisualizer&lt;/th&gt;
&lt;th&gt;Python Tutor&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Languages&lt;/td&gt;
&lt;td&gt;JavaScript only&lt;/td&gt;
&lt;td&gt;Python, Java, C, C++, JavaScript&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Step size&lt;/td&gt;
&lt;td&gt;4 levels (expression, statement, human-friendly, function), forward and back&lt;/td&gt;
&lt;td&gt;1 level (line), forward and back&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Visualizations&lt;/td&gt;
&lt;td&gt;12 views, switchable via tabs&lt;/td&gt;
&lt;td&gt;1 (frames and objects diagram)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Which expression is running&lt;/td&gt;
&lt;td&gt;Highlights the exact expression&lt;/td&gt;
&lt;td&gt;An arrow points to the line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The big picture of recursion (call tree, expansion by substitution)&lt;/td&gt;
&lt;td&gt;Call Tree and Subst views&lt;/td&gt;
&lt;td&gt;In JavaScript mode, frames disappear once a call returns&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sharing&lt;/td&gt;
&lt;td&gt;Links that open specific code (via &lt;code&gt;?code=&lt;/code&gt;, see below)&lt;/td&gt;
&lt;td&gt;Shareable links and embed codes for a specific run&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Python Tutor's diagram — frames on the left, objects on the right, arrows for references — is an excellent way to understand &lt;strong&gt;how variables relate to memory&lt;/strong&gt;. JSVisualizer has a view of the same kind, called &lt;strong&gt;Memory&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Where JSVisualizer differs is that you're not limited to that one diagram. &lt;strong&gt;You pick the view that fits the question you're asking&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How does a variable change as a loop runs? → Variable, Exec Trace&lt;/li&gt;
&lt;li&gt;How does a complicated condition turn into &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;? → Expr (stepping one expression at a time)&lt;/li&gt;
&lt;li&gt;Which branch of an &lt;code&gt;if&lt;/code&gt; did the program take? → Control Flow&lt;/li&gt;
&lt;li&gt;Is my recursive function computing the same thing over and over? → Call Tree&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  So which one should you use?
&lt;/h3&gt;

&lt;p&gt;Honestly, it's not about which is better — &lt;strong&gt;they shine in different situations&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reach for Python Tutor when you…&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;are learning Python, C, or another language besides JavaScript&lt;/li&gt;
&lt;li&gt;want to really understand variables, references, and memory ("boxes and arrows")&lt;/li&gt;
&lt;li&gt;want to hand students a single link that replays one specific run&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Reach for JSVisualizer when you…&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;are learning or teaching JavaScript&lt;/li&gt;
&lt;li&gt;want to see things a memory diagram can't easily show: evaluation order, which lines ran and how often, how recursion branches out&lt;/li&gt;
&lt;li&gt;want to look at the same program from several angles&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  For instructors: links that open specific code
&lt;/h2&gt;

&lt;p&gt;You can add parameters to the URL so that JSVisualizer opens with a specific piece of code already loaded:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://tntetsu.github.io/JSVisualizer/?code=&amp;lt;URL of a code JSON&amp;gt;&amp;amp;view=&amp;lt;view to show first&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;code&lt;/code&gt;: the URL of a JSON file shaped like &lt;code&gt;{ "title": "...", "code": "..." }&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;view&lt;/code&gt;: the view that opens the first time the reader presses &lt;strong&gt;▶ Run&lt;/strong&gt; (&lt;code&gt;trace&lt;/code&gt;, &lt;code&gt;subst&lt;/code&gt;, &lt;code&gt;controlflow&lt;/code&gt;, …)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Put a link like this in your slides or assignments — "open this, press Run, and step through it" — and every student starts from the same screen without retyping any code. Every post in this series ends with a link in this format.&lt;/p&gt;

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

&lt;p&gt;This link opens the factorial example from this post. Press &lt;strong&gt;▶ Run&lt;/strong&gt; and the Subst view opens. Use &lt;strong&gt;▷ Human&lt;/strong&gt; to step forward, and try switching between tabs as you go.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://tntetsu.github.io/JSVisualizer/?code=https%3A%2F%2Ftntetsu.github.io%2FJSVisualizer%2Fsamples%2Farticles%2F00-factorial.en.json&amp;amp;view=subst" rel="noopener noreferrer"&gt;▶ Open in JSVisualizer (factorial, Subst view)&lt;/a&gt;&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;fact&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;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;fact&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;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;fact&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course, you can also open the home page and paste in your own code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;JSVisualizer is a web app that steps through JavaScript and lets you watch it run through 12 different views.&lt;/li&gt;
&lt;li&gt;You can step at four levels of detail, and step backward at every level.&lt;/li&gt;
&lt;li&gt;Beyond the memory diagram that Python Tutor does so well, you can pick a view that matches your question: evaluation order, branching, execution counts, or how recursion unfolds.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Next up:&lt;/strong&gt; the first big hurdle in programming — the &lt;strong&gt;&lt;code&gt;for&lt;/code&gt; loop&lt;/strong&gt;. We'll take the classic "add up 1 through 5" program and use the &lt;strong&gt;Variable&lt;/strong&gt; view to follow &lt;code&gt;sum&lt;/code&gt; and &lt;code&gt;i&lt;/code&gt; one step at a time.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>education</category>
      <category>visualization</category>
    </item>
  </channel>
</rss>
