title: How many data types are there in JavaScript, what are they, and what is considered a type?
body: <p>I'm curious how many types there are in JS, because I have read conflicting answers from otherwise reliable sources:</p>
  <p><strong>If we look at the <a href="https://262.ecma-international.org/11.0/#sec-ecmascript-data-types-and-values" rel="nofollow noreferrer">ECMAScript spec</a>, there are 8 types:</strong></p>
  <ul>
  <li>Undefined, Null, Boolean, String, Symbol, Number, BigInt, and Object</li>
  </ul>
  <p>It seems <code>function</code> is counted as object.</p>
  <hr />
  <p><strong>If we look at <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures" rel="nofollow noreferrer">MDN</a>, they say there is 9 types:</strong></p>
  <p>Six Data Types that are primitives, checked by typeof operator:</p>
  <ol>
  <li>undefined : typeof instance === &quot;undefined&quot;</li>
  <li>Boolean : typeof instance === &quot;boolean&quot;</li>
  <li>Number : typeof instance === &quot;number&quot;</li>
  <li>String : typeof instance === &quot;string&quot;</li>
  <li>BigInt : typeof instance === &quot;bigint&quot;</li>
  <li>Symbol : typeof instance === &quot;symbol&quot;</li>
  </ol>
  <p>Structural Types:</p>
  <ol start="7">
  <li>Object : typeof instance === &quot;object&quot;. Special non-data but Structural type for any constructed object instance also used as data structures: new Object, new Array, new Map, new Set, new WeakMap, new WeakSet, new Date and almost everything made with new keyword;</li>
  <li>Function : a non-data structure, though it also answers for typeof operator: typeof instance === &quot;function&quot;. This is merely a special shorthand for Functions, though every Function constructor is derived from Object constructor.</li>
  </ol>
  <p>Structural Root Primitive:</p>
  <ol start="9">
  <li>null : typeof instance === &quot;object&quot;. Special primitive type having additional usage for its value: if object is not inherited, then null is shown;</li>
  </ol>
  <p>Which one of these is correct?</p>