Immutability is not enough
I think this is an example of something I see often, where a particular idea (e.g. immutability, interfaces, modularity, etc.) gets confused with a particular feature of a particular language which shares the same name. In this case, the author&#x27;s code isn&#x27;t using immutability; it just-so-happens to be creating an object called &quot;Immutable.Map&quot;.<p>Following the author&#x27;s terminology, mutability is when we replace the contents of a memory location with different values, e.g.:<p><pre><code>     Time | RAM
    ------+--------------------------------
     0    | foo
     1    | bar
     2    | baz
          .
          .
          .
</code></pre>
The author is using the term immutable to mean never replacing the contents of a memory location, so in their view this is immutability:<p><pre><code>     Time | RAM 1 | RAM 2 | RAM 3 |
    ------+-------+-------+-------+--...
     0    | foo   |       |       |
     1    | foo   | bar   |       |
     2    | foo   | bar   | baz   |
          .       .       .       .
          .       .       .       .
          .       .       .       .
</code></pre>
However, this is really just an implementation detail; Javascript programming isn&#x27;t really about values in RAM (unlike, e.g. C where pointers are first-class values in the language). Instead, Javascript is conceptually built around variables, objects, scope, etc. So let&#x27;s see how these RAM details translate to the values of variables.<p>The &quot;mutable&quot; version:<p><pre><code>     Time | &quot;state&quot; var
    ------+-------------
     0    | foo
     1    | bar
     2    | baz
          .
          .
          .
</code></pre>
The &quot;immutable&quot; version:<p><pre><code>     Time | &quot;state&quot; var 0 | &quot;state&quot; var 1 | &quot;state&quot; var 2 |
    ------+---------------+---------------+---------------+--...
     0    | foo           |               |               |
     1    | foo           | bar           |               |
     2    | foo           | bar           | baz           |
          .               .               .               .
          .               .               .               .
          .               .               .               .
</code></pre>
So far so good. However, scope plays a large part in Javascript programming: we can only access variables which are in scope, and what&#x27;s more the <i>same</i> variable name can refer to <i>different</i> values depending on the scope we&#x27;re in. This is where the author confuses the <i>concept</i> of immutability with the name of a library they just-so-happen to be using. Their code keeps generating new scopes, in which the variable name &quot;state&quot; refers to a different value than in the previous scopes. Conceptually, the variable &quot;state&quot; is not immutable because it keeps referring to different things, even though the implementation details could be argued to be immutable.<p>As an analogy, consider a display which shows the current value of a stock price. That is certainly not immutable, and trying to use that reading to perform calculations will be tricky since it keeps changing. This is like the author&#x27;s original, mutable &quot;state&quot; variable.<p>Now consider a plotter drawing a graph of how that price varies over time:<p><pre><code>          |
          |    _--.      ____
    Price |   &#x2F;    \    &#x2F;    \
          |__&#x2F;      \__;      \__&#x2F;
          |                       
          +-----------------------------------
               Time              ^
                                 |
                                Now
</code></pre>
This is like the author&#x27;s &quot;immutable&quot; version, where values are never changed once they&#x27;re defined. This seems more useful for performing calculations, however, because the author keeps creating new scopes, they have no access to these old values! We have no access to the graph paper, we&#x27;re only allowed to see the current position of the pen; which is exactly the same as if we only had the original display!<p>If we take scope into account, we actually get the following:<p>Mutable version:<p><pre><code>     Time | Scope | Current &quot;state&quot;
    ------+-------+-----------------
     0    | 0     | foo
     1    | 0     | bar
     2    | 0     | baz
          .       .
          .       .
          .       .
</code></pre>
Immutable version:<p><pre><code>     Time | Scope | Current &quot;state&quot; | &quot;state&quot; var 0 | &quot;state&quot; var 1 | &quot;state&quot; var 2 |
    ------+-------+-----------------+---------------+---------------+---------------+--...
     0    | 0     | foo             | foo           |               |               |
     1    | 1     | bar             | foo           | bar           |               |
     2    | 2     | baz             | foo           | bar           | baz           |
          .       .                 .               .               .               .
          .       .                 .               .               .               .
          .       .                 .               .               .               .
</code></pre>
I do think the author has a few good points to make; however, I don&#x27;t think it&#x27;s an argument between being mutable vs. being immutable, so much as one between being implicit vs. being explicit.