title: Array destructing from Object.entries in Javascript
body: <p>Here is the code in question:</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 posts = [{
    data: {
      id: 1,
      date: "2019-02-03",
      ev_filter_1: ["art", "foodie"],
      ev_filter_2: ["value1", "value2"],
      ev_filter_3: ["value1", "value2"],
      ev_filter_4: ["all", "12+"]
    }
  },
    {
      data: {
        id: 2,
        date: "",
        ev_filter_1: ["arti", "foodie"],
        ev_filter_2: ["value1", "value2"],
        ev_filter_3: ["value1", "value2"],
        ev_filter_4: ["all", "19+"]
      }
    },
    {
      data: {
        id: 3,
        date: "2019-02-03",
        ev_filter_1: ["art", "foodie"],
        ev_filter_2: ["value1", "value75"],
        ev_filter_3: ["value1", "value2"],
        ev_filter_4: ["all", "12+"]
      }
    }
  ];
  
  function sift2(arrObjLit, pattern, ...values) {
    const toMatch = new Set(values)
    const result = arrObjLit.map(o =&gt; o.data)
    .filter(o =&gt;
        Object.entries(o)
        .filter(([k, v]) =&gt; {
          console.log(`${k}: ${v}`)
          return true
        })
        .filter(([k, v]) =&gt; k.startsWith(pattern))
        .filter(([k, v]) =&gt; Array.isArray(v))
        .filter(([k, v]) =&gt; toMatch.has(v))
            .length &gt; 0
    )
    return result;
  }
  
  console.log(...sift2(posts, "ev_", "value75", "12+"));</code></pre>
  </div>
  </div>
  </p>
  
  <p>Which is baffling me. Based on <a href="https://stackoverflow.com/questions/45026162/javascript-array-de-structuring-and-object-entries?noredirect=1#comment77026918_45026162">this post</a>
  I would expect the array destructing in <code>filter</code> to be wrong. And yet, it's not. It's exactly what I am looking for. Why would the destructing be flat in the <code>filter</code> method? Am I observing things wrong?</p>
  
  <pre><code>.filter(o =&gt;
        Object.entries(o)
        .filter(([k, v]) =&gt; k.startsWith(pattern))
  </code></pre>