title: Does Array.filter make a clone (copy) of the array?
body: <p>My understandig was that <strong>Array.filter</strong> creates a clone of the object, but in the example below both type1 and type1a obviously share the some data.</p>
  
  <pre><code>let initial = [
     {id: 1, type: 1, name: "first", count:0},
     {id: 2, type: 2, name: "second", count:0},
     {id: 3, type: 1, name: "third", count:0},
     {id: 4, type: 2, name: "fourth", count:0},
  ];
  
  let type1 = initial.filter((item)=&gt;item.type===1);
  let type1a = initial.filter((item)=&gt;item.type===1);
  
  type1[0].count = 2;
  
  console.log(type1a[0].count);
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>Expected result: 0
  Got: 2
  </code></pre>
  
  <p>What am I missing?</p>
  
  <p>I have tried adding the spread operator in both assignemnet but the result is the same :(</p>
  
  <hr>
  
  <p>Thanks to @Thomas for the answer.</p>
  
  <p>For your reference, the correct code is:</p>
  
  <pre><code>let initial = [
    { id: 1, type: 1, name: "first", count: 0 },
    { id: 2, type: 2, name: "second", count: 0 },
    { id: 3, type: 1, name: "third", count: 0 },
    { id: 4, type: 2, name: "fourth", count: 0 }
  ];
  
  // let type1 = initial.filter(item =&gt; item.type === 1);
  let type1 = [];
  initial.forEach((item)=&gt;{
    if(item.type === 1)
      type1.push(JSON.parse(JSON.stringify(item))
      )
  })
  
  // let type1a = initial.filter(item =&gt; item.type === 1);
  
    let type1a = [];
    initial.forEach((item)=&gt;{
      if(item.type === 1)
        type1a.push(JSON.parse(JSON.stringify(item))
        )
    })
  
    type1[0].count = 2;
  
    console.log(type1[0].count);
    console.log(type1a[0].count);
  </code></pre>