title: Check if an object's immediately inherits from constructor
body: <p>The <code>instanceof</code> operator is not suitable for purposes that require only a value's parent in the inheritance chain to be checked.</p>
  
  <p>Here is an instance where using <code>instanceof</code> to check an object's type returns positives that are false for the above:</p>
  
  <pre><code>{} instanceof Object; // returns true, the desired result
  [] instanceof Object; // returns true, not the desired result
  </code></pre>
  
  <p><code>instanceof</code> checks if whatever is on the right-hand side exists anywhere in the prototype chain of whatever is on the left-hand side. That is as intended, but if I want to know if a value is a plain object, for example. If I have:</p>
  
  <ul>
  <li>a prototype/class <code>Interrupt</code>,</li>
  <li>a prototype/class <code>HardwareInterrupt</code> that inherits from <code>Interrupt</code>,</li>
  <li>a prototype/class <code>SoftwareInterrupt</code> that inherits from <code>Interrupt</code>,</li>
  <li>a prototype/class <code>MaskableInterrupt</code> that inherits from <code>HardwareInterrupt</code>,</li>
  <li>and a prototype/class <code>NonmaskableInterrupt</code> that inherits from <code>HardwareInterrupt</code>,</li>
  </ul>
  
  <p>then if I want to know whether or not an object is immediately below <code>Interrupt</code> in the hierarchy, <code>instanceof</code> can return an inaccurate result like <code>Nonmaskable instanceof Interrupt</code> evaluating to <code>true</code>. What way will only check an object's immediate ancestor prototype/class against a given prototype/class?</p>
  
  <p>What's the right terminology to use to speak of what an object was instantiated from, anyway? While writing this question I wanted to say "type", but I realized that it's also valid to say, as an example, a maskable interrupt is a type of hardware interrupt (though I can think of examples where using "type" like this would be incorrect). And since there are prototypes and classes in JavaScript, is there a word that can be swapped in for writing "prototype/class"?</p>