title: Copy array of objects and make changes without modifying original array
body: <p>I have an array of objects. I would like to deep copy the array of objects and make some changes to each object. I want to do this without modifying the original array or original objects that were in that array.</p>
  
  <p>This is the way I have done it. However, being new to JavaScript I want to make sure this is a good approach.  </p>
  
  <p>Is there a better way to do this?</p>
  
  <pre><code>const users = 
  [
      {
          id       : 1,    
          name     : 'Jack',
          approved : false
      },
      {
          id       : 2,    
          name     : 'Bill',
          approved : true
      },
      {
          id       : 3,    
          name     : 'Rick',
          approved : false
      },
      {
          id       : 4,    
          name     : 'Rick',
          approved : true
      }
  ];
  
  
  const users2 = 
      users
          .map(
              (u) =&gt; 
              {
                  return Object.assign({}, u);
              }
          )    
          .map(
              (u) =&gt; 
              {
                  u.approved = true;
                  return u;
              }
          );    
  
  
  console.log('New users2 array of objects:')
  console.log(users2);
  
  console.log('This was original users array is untouched:')
  console.log(users);
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>New users2 array of objects:
  [ { id: 1, name: 'Jack', approved: true },
    { id: 2, name: 'Bill', approved: true },
    { id: 3, name: 'Rick', approved: true },
    { id: 4, name: 'Rick', approved: true } ]
  This was original users array is untouched:
  [ { id: 1, name: 'Jack', approved: false },
    { id: 2, name: 'Bill', approved: true },
    { id: 3, name: 'Rick', approved: false },
    { id: 4, name: 'Rick', approved: true } ]
  </code></pre>