Immutable.js - why does calling map() on a Record mutate the original object?
<p>Let's create an <code>Immutable.Record</code> and modify it with <code>map</code>:</p>

<pre><code>let R = Immutable.Record({a:1,b:2});
let r = new R();
let q = r.map(i =&gt; i * 2);
</code></pre>

<p>I'd expect that <code>r</code> remains unmodified and <code>q</code> is <code>Record { a:2, b:4 }</code>. But the actual result is that <code>r</code> was mutated and <code>q</code> (the return value from <code>map()</code> is <code>undefined</code>.</p>

<p>Why was the immutable object mutated? What are the rules that determine when an object is mutated in-place and when a new instance is returned?</p>