<?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>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="nx"&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="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;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="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sum&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 write down each variable's value line by line, crossing out and rewriting whenever something changes. It works, but it's tedious, and one slip of the pencil can leave you more confused than before.&lt;/p&gt;

&lt;p&gt;JSVisualizer's Variable view &lt;strong&gt;builds that table for you, automatically, as the program runs&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: the &lt;code&gt;i&lt;/code&gt; on line 3 is always 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. When the loop ends, &lt;code&gt;i&lt;/code&gt; is 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;exists only inside the loop&lt;/strong&gt;, so it's gone once the loop finishes. 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 ends?&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. It's a trace table that builds itself.&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 history&lt;/strong&gt; so you can see how you got here (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>
