title: Does spread operator affect performance?
body: <p>I am considering the below two approaches for building an array of objects:</p>
  
  <p>Approach 1 (list all properties, even if duplicated among objects):</p>
  
  <pre><code>const employees = [
    {
      company: 'ABC',
      country: 'IN',
      zip: 123,
      employeeId: 123,
      employeeName: 'p'
    },
    {
      company: 'ABC',
      country: 'IN',
      zip: 123,
      employeeId: 456,
      employeeName: 'q'
    },
    {
      company: 'ABC',
      country: 'IN',
      zip: 123,
      employeeId: 789,
      employeeName: 'r'
    }
  ];
  </code></pre>
  
  <p>Approach 2 (avoid duplication with the <em>spread operator</em>):</p>
  
  <pre><code>const commonParams = {
    company: 'ABC',
    country: 'IN',
    zip: 123
  };
  
  const employees = [
    {
      ...commonParams,
      employeeId: 123,
      employeeName: 'p'
    },
    {
      ...commonParams,
      employeeId: 456,
      employeeName: 'q'
    },
    {
      ...commonParams,
      employeeId: 789,
      employeeName: 'r'
    }
  ]
  </code></pre>
  
  <p>Approach 2 is more succint, and adding a new property that is common to all array elements would be much easier (and less prone to errors).</p>
  
  <p>However, in case of a large <code>commonParams</code> object, does approach 2 (using the <em>spread operator</em>) affect performance as compared to approach 1?</p>
  
  <p>Would the spread operator loop through each of the properties of the <code>commonParams</code> object for each of the objects in the <code>employees</code> array?</p>