title: value has been overrite in nested forLoop issue
body: <p>I am not sure what' wrong with my code, value has been override in the nested for-loop, please help me debug following code. var1 is an array that contains another array called list. Var2 is also an array, and each var2.data is equal to the var1. I tried to setup the list.id = var2.index of each var2.data, but for some reason that all the list.id inside of var2 are equal 2, seems like that value has been override. Please see below:</p>
  
  <pre><code>    let var1 = [{
          'name': 'name1',
          'list': [{
              id: 0,
              a: "test1",
              b: 'test2'
            },
            {
              id: 0,
              a: "aac",
              b: 'test2'
            },
            {
              id: 0,
              a: "aad",
              b: 'test2'
            },
          ]
        },
        {
          'name': 'name2',
          'list': [{
              id: 0,
              a: "test1",
              b: 'test2'
            },
            {
              id: 0,
              a: "aac",
              b: 'test2'
            },
            {
              id: 0,
              a: "aad",
              b: 'test2'
            },
          ]
        }
      ];
  
      let var2 = [{
          claim: 'claim1',
          ifn: '1',
          data: []
        },
        {
          claim: 'claim2',
          ifn: '2',
          data: []
        },
        {
          claim: 'claim3',
          ifn: '3',
          data: []
        },
      ]
  
      var2.forEach((item, i) =&gt; {
        var1.forEach(list =&gt; {
          list.list.forEach(val =&gt; {
            val.id = i;
          })
          item.data = list;
        })
      })
     console.log(var2)
  </code></pre>
  
  <p>I would like to have that each list.id equal the index of var2, like below, really not sure how to make this code work, please help~</p>
  
  <pre><code>var2 = [
  { claim:'claim1',ifn:'1',
    data:
        [{
          'name':'name1',
          'list':[
              {id:0,a:"test1",b:'test2'},
              {id:0,a:"aac",b:'test2'},
              {id:0,a:"aad",b:'test2'},
                 ]
          },
          {
           'name':'name2',
           'list':[
                  {id:0,a:"test1",b:'test2'},
                  {id:0,a:"aac",b:'test2'},
                  {id:0,a:"aad",b:'test2'},
                 ]
        }]
  },
  { claim:'claim2',ifn:'2',
    data:
        [{
          'name':'name1',
          'list':[
              {id:1,a:"test1",b:'test2'},
              {id:1,a:"aac",b:'test2'},
              {id:1,a:"aad",b:'test2'},
           ]
          },
      {
      'name':'name2',
          'list':[
                  {id:1,a:"test1",b:'test2'},
                  {id:1,a:"aac",b:'test2'},
                  {id:1,a:"aad",b:'test2'},
                 ]
        }]
  },
  { claim:'claim3',ifn:'3',
    data:[{
          'name':'name1',
          'list':[
                  {id:2,a:"test1",b:'test2'},
                  {id:2,a:"aac",b:'test2'},
                  {id:2,a:"aad",b:'test2'},
                  ]
          },
          {
          'name':'name2',
          'list':[
              {id:2,a:"test1",b:'test2'},
                  {id:2,a:"aac",b:'test2'},
                  {id:2,a:"aad",b:'test2'},
                 ]
       }]
    }
  ]
  </code></pre>