title: JS How does the in operator work on object with array
body: <p>Line 64 of this <a href="https://github.com/sindresorhus/screenfull.js/blob/gh-pages/src/screenfull.js" rel="nofollow noreferrer">fullscreen github project</a> checks if an array is in an object, <code>if (val &amp;&amp; val[1] in document)</code>, like in the example below.</p>
  
  <p>I understand 'in' operator for normal properties but how does this work for arrays? I don't understand how this passes if you are in a webkit browser.</p>
  
  <pre><code>const webkit = [
      'webkitRequestFullscreen',
      'webkitExitFullscreen',
      'webkitFullscreenElement',
      'webkitFullscreenEnabled',
      'webkitfullscreenchange',
      'webkitfullscreenerror'
  ],
  
  if (webkit in document) {
      //Passes
  }
  </code></pre>
  
  <p>I'm using JSDOM and need to add these webkit properties to a fake document. I'v tried to replicate this like so:</p>
  
  <pre><code>const document = {
      webkitRequestFullscreen = () =&gt; null;
      webkitExitFullscreen = () =&gt; null;
      webkitFullscreenElement = null;
      webkitFullscreenEnabled = true;
      webkitfullscreenchange = () =&gt; null;
      webkitfullscreenerror = () =&gt; null;
  }
  </code></pre>
  
  <p>but the <code>in</code> operator check fails.</p>