title: Working on transforming array object data where it's taking same value for each indexes while converting it to other format
body: <p>I have an issue transforming array object data into required format. With my solution it's transforming it correctly but it's copying same last index data for each item in array.</p>
  <h4>Input:</h4>
  <pre><code>let data = [
    {
      0: {
        value1: true,
        value2: false,
        isSelected: false,
      },
      1: {
        value1: true,
        value2: true,
        isSelected: true,
      },
      2: {
        value1: false,
        value2: false,
        isSelected: false,
      },
      3: {
        value1: false,
        value2: false,
        isSelected: false,
      },
      4: {
        value1: true,
        value2: true,
        isSelected: true,
      },
      Stage: 'A',
    },
    {
      0: {
        value1: false,
        value2: false,
        isSelected: false,
      },
      1: {
        value1: true,
        value2: true,
        isSelected: true,
      },
      2: {
        value1: false,
        value2: false,
        isSelected: false,
      },
      3: {
        value1: false,
        value2: false,
        isSelected: false,
      },
      4: {
        value1: true,
        value2: true,
        isSelected: true,
      },
      Stage: 'B',
    },
    {
      0: {
        value1: false,
        value2: false,
        isSelected: false,
      },
      1: {
        value1: true,
        value2: true,
        isSelected: true,
      },
      2: {
        value1: false,
        value2: false,
        isSelected: false,
      },
      3: {
        value1: false,
        value2: false,
        isSelected: false,
      },
      4: {
        value1: true,
        value2: true,
        isSelected: true,
      },
      Stage: 'C',
    },
  ];
  </code></pre>
  <h4>Expected output:</h4>
  <pre><code>// Expected output data
  [
    {
      Stage: [
        {
          value1: true,
          value2: false,
          isSelected: false,
        },
        {
          value1: true,
          value2: true,
          isSelected: true,
        },
        {
          value1: false,
          value2: false,
          isSelected: false,
        },
        {
          value1: false,
          value2: false,
          isSelected: false,
        },
        {
          value1: true,
          value2: true,
          isSelected: true,
        },
      ],
    },
    {
      Stage: [
        {
          value1: false,
          value2: false,
          isSelected: false,
        },
        {
          value1: true,
          value2: true,
          isSelected: true,
        },
        {
          value1: false,
          value2: false,
          isSelected: false,
        },
        {
          value1: false,
          value2: false,
          isSelected: false,
        },
        {
          value1: true,
          value2: true,
          isSelected: true,
        },
      ],
    },
    {
      Stage: [
        {
          value1: false,
          value2: false,
          isSelected: false,
        },
        {
          value1: true,
          value2: true,
          isSelected: true,
        },
        {
          value1: false,
          value2: false,
          isSelected: false,
        },
        {
          value1: false,
          value2: false,
          isSelected: false,
        },
        {
          value1: true,
          value2: true,
          isSelected: true,
        },
      ],
    },
  ];
  </code></pre>
  <h4>What I've tried:</h4>
  <pre><code>stagesBackTransform = (data) =&gt; {
    let newArr = new Array(data.length).fill({ Stage: new Array(16) });
  
    data.forEach((stage, stageIdx) =&gt; {
      Object.entries(stage).forEach((item, idx) =&gt; {
        if (item[0] !== 'Stage') {
          // newArr[stageIdx].Stage[item[0]] = item[1];
          newArr[stageIdx].Stage[idx] = item[1];
        }
      });
    });
    console.log('new:', newArr);
    return newArr;
  };
  </code></pre>
  <p><div class="snippet" data-lang="js" data-hide="true" data-console="true" data-babel="false">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let data = [
    {
      0: { value1: true, value2: false, isSelected: false },
      1: { value1: true, value2: true, isSelected: true },
      2: { value1: false, value2: false, isSelected: false },
      3: { value1: false, value2: false, isSelected: false },
      4: { value1: true, value2: true, isSelected: true },
      Stage: 'A',
    },
    {
      0: { value1: false, value2: false, isSelected: false },
      1: { value1: true, value2: true, isSelected: true },
      2: { value1: false, value2: false, isSelected: false },
      3: { value1: false, value2: false, isSelected: false },
      4: { value1: true, value2: true, isSelected: true },
      Stage: 'B',
    },
    {
      0: { value1: false, value2: false, isSelected: false },
      1: { value1: true, value2: true, isSelected: true },
      2: { value1: false, value2: false, isSelected: false },
      3: { value1: false, value2: false, isSelected: false },
      4: { value1: true, value2: true, isSelected: true },
      Stage: 'C',
    },
  ];
  
  stagesBackTransform = (data) =&gt; {
    let newArr = new Array(data.length).fill({ Stage: new Array(16) });
  
    data.forEach((stage, stageIdx) =&gt; {
      Object.entries(stage).forEach((item, idx) =&gt; {
        if (item[0] !== 'Stage') {
          // newArr[stageIdx].Stage[item[0]] = item[1];
          newArr[stageIdx].Stage[idx] = item[1];
        }
      });
    });
    console.log('new:', newArr);
    return newArr;
  };
  
  const result = stagesBackTransform(data);
  
  console.log(result);</code></pre>
  </div>
  </div>
  </p>
  <p>It's giving me output in expected format but it's copying same item[1] which is object. It's copying last index object at all indexes in newly created arr.
  What mistake I'm doing here in my current code?</p>