title: How to use array .filter() to search key value in JSON array of objects
body: <p>If I have an array of objects like so in <code>playlists.json</code></p>
  <pre><code>&quot;playlists&quot; : [
        {
          &quot;id&quot; : &quot;1&quot;,
          &quot;owner_id&quot; : &quot;2&quot;,
          &quot;song_ids&quot; : [
            &quot;8&quot;,
            &quot;32&quot;
          ]
        },
        {
          &quot;id&quot; : &quot;2&quot;,
          &quot;owner_id&quot; : &quot;3&quot;,
          &quot;song_ids&quot; : [
            &quot;6&quot;,
            &quot;8&quot;,
            &quot;11&quot;
          ]
        },
        {
          &quot;id&quot; : &quot;3&quot;,
          &quot;owner_id&quot; : &quot;7&quot;,
          &quot;song_ids&quot; : [
            &quot;7&quot;,
            &quot;12&quot;,
            &quot;13&quot;,
            &quot;16&quot;,
            &quot;2&quot;
          ]
        }
      ]
  </code></pre>
  <p>and in Node I read in the file like this:</p>
  <pre><code>const data = JSON.parse(fs.readFileSync('playlists.json'));
  </code></pre>
  <p>I want to write a <code>.filter()</code> function that can search by <code>id</code> and mutate the result into a new array thereby removing the entry tested for.</p>
  <p>Of course we can access the index like this: <code>playlists[0].id);</code></p>
  <p>How would write the <code>.filter()</code> to test for a certain <code>id</code> i.e. generate a new array with value removed? (mutate) I wrote some code below but it is wrong and noob.</p>
  <pre><code>const someId = &quot;2&quot;
  const result = playlists.filter(playlist =&gt; playlist.id !== someId)
  </code></pre>
  <p>New array of <code>result</code> would contain:</p>
  <pre><code>&quot;playlists&quot; : [
        {
          &quot;id&quot; : &quot;1&quot;,
          &quot;owner_id&quot; : &quot;2&quot;,
          &quot;song_ids&quot; : [
            &quot;8&quot;,
            &quot;32&quot;
          ]
        },
        {
          &quot;id&quot; : &quot;3&quot;,
          &quot;owner_id&quot; : &quot;7&quot;,
          &quot;song_ids&quot; : [
            &quot;7&quot;,
            &quot;12&quot;,
            &quot;13&quot;,
            &quot;16&quot;,
            &quot;2&quot;
          ]
        }
      ]
  </code></pre>