title: Comparison logic on Value and it's Prototype
body: <p>So, there is a &quot;<em>problem</em>&quot;:<br/>
  You have</p>
  <pre><code>let kind_1_ = &quot;some_string&quot;
  let kind_2_ = 1234
  let kind_3_ = [ &quot;can be string or...&quot;, 0, { &quot;some_prop&quot; : &quot;any possible type of value&quot; }, [&quot;...or this&quot;] ]
  let kind_4_ = { &quot;even_this&quot; : &quot;will be appropriate&quot; }
  
  const prototype = [ &quot;string&quot;, 0, [], {} ]
  /* as well as   = [ &quot;string&quot;, 0, [] ]       */
  /* or as        = [ 0, {} ]                 */
  /* and so on... but in most cases with this
     | 4 particular types                     */
  </code></pre>
  <p>So, we have to compare <strong>kind</strong>s to the <strong>prototype</strong>. There is only <strong>1 kind</strong> and <strong>1 prototype</strong> given at the time. My code for this was as simple as this:<br/></p>
  <pre><code>let this_will_be_called = (kind, proto) =&gt; {
      let bool_to_return = false
      for (let each in proto)
      {
          if (typeof(kind) == typeof(proto)) {
              bool_to_return = true
              return bool_to_return
          }
      }
      return bool_to_return
  }
  
  this_will_be_called(kind_any_of_kinds, prototype)
  </code></pre>
  <p>Of course, it's not working the way it should. One <em>Major</em> problem is that you can't effectively compare [] to {}, because they are both of type <strong>Object</strong> (<em>I know about Array.isArray()</em>). But in case of the following situations, it must return <strong>false</strong>:</p>
  <pre><code>let kind = []
  var prototype = [.., {}] /* without [] in here */
  
  /* or this */
  let kind = {}
  var prototype = [.., []] /* without {} in here */
  
  /* but must return true if: */
  let kind = {} /* or let kind = [] */
  var prototype = [.., [], {}]
  </code></pre>
  <p>And in the end, it must return <strong>false</strong> if no types matching.<br/>
  My logic is explained in this <em>pseudo-code</em>:</p>
  <pre><code>FOR every element in prototype:
      IF (type of element == type of kind) and (element is NOT Array):
          return TRUE
      ELSE IF (type of element == type of kind) and (element is Array):
          IF (type of kind is NOT an Object) and (kind is Array):
              return TRUE
          ELSE IF (type of kind is an Object):
              return FALSE
      ELSE IF (type of element == type of kind) and (element is Object) and (element is NOT an Array):
          IF (kind is NOT an Array):
              return TRUE
          ELSE IF (kind is an Array):
              return FALSE
      ELSE:
          return FALSE
  </code></pre>
  <p>Now, I need your attention to <strong>audit</strong> my logic, because I've completely broke my brain on solving this. Even if above logic works, it's not an elegant solution. So, you could modify it for better performance.<br/>
  <br/>
  My appreciation on <strong>every</strong> solution! ;)</p>