title: What does it mean that `toString` gets “ignored” if it returns a non-primitive?
body: <p>The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString#overriding_the_default_tostring_method" rel="nofollow noreferrer">MDN documentation on <code>Object.prototype.toString</code></a> says that when <code>toString</code> gets overriden, it should only return a primitive value:</p>
  <blockquote>
  <p>The <code>toString()</code> function you create must return a primitive, otherwise it will be ignored.</p>
  </blockquote>
  <p>However, in the following example we return an object inside of <code>toString</code> and it returns the object normally:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const ob2 = {
      val1: 100,
      val2: 200,
      toString: function() {
        return {
          veh: "meh"
        }; // Object.
      }
    };
  
  console.log(ob2.toString());</code></pre>
  </div>
  </div>
  </p>
  <p>Output:</p>
  <pre class="lang-js prettyprint-override"><code>{ veh: &quot;meh&quot; }
  </code></pre>
  <p>So the <code>toString</code> method returns the object normally. What is up with the misinformation?</p>