# 2 2D Arrays ending up being the same, when For-loop modifies one

**URL:** <https://forum.kirupa.com/t/2-2d-arrays-ending-up-being-the-same-when-for-loop-modifies-one/269285>\
**Category:** Uncategorized\
**Created:** [August 25, 2008, 6:21pm UTC](https://forum.kirupa.com/t/2-2d-arrays-ending-up-being-the-same-when-for-loop-modifies-one/269285 "2008-08-25T18:21:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrRobot](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/drrobot/32/3907_2.png) [@DrRobot](https://forum.kirupa.com/u/DrRobot)\
**Post date:** [August 25, 2008, 6:21pm UTC](https://forum.kirupa.com/t/2-2d-arrays-ending-up-being-the-same-when-for-loop-modifies-one/269285/1 "2008-08-25T18:21:01Z")

</div>

Alright, so i’m doing some minor data copying from another array, and for some reason both arrays end up being the same. i never really change any properties of the first array…  
here is my class:

```auto

package 
{
 import flash.display.Sprite;
 import flash.events.Event;
 
 public class Main extends Sprite
 {
  public var current:Array = [];
  public var map:Array = [
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  ];
  
  public function Main():void
  {
   testFunk();
  }
  private function testFunk():void 
  {
   trace(map[0]);
   for (var r:int = 0; r < 9; r++)
   {
    current.push(map[r]);
    current[current.length-1].splice(9, 4);
    for (var c:int = 0; c < 10; c++)
    {
     current[r][c] = 2;
    }
   }
   trace(map[0]);
   trace(current[0]);
   trace(map);
  }
 }
}

```

and the traces output as:

```auto

[SIZE=1][COLOR=#808080][SIZE=1][COLOR=#808080][Capturing traces with FDB]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=1]0,0,0,0,0,0,0,0,0,0,0,0,0,0
2,2,2,2,2,2,2,2,2,2
2,2,2,2,2,2,2,2,2,2
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
[/SIZE]

```

why did map turn into current? what’s the deal with this?
