# \[CS5.5\] Unusual array behaviour

**URL:** https://forum.kirupa.com/t/cs5-5-unusual-array-behaviour/331292
**Category:** flash
**Created:** [June 30, 2013, 11:11am UTC](https://forum.kirupa.com/t/cs5-5-unusual-array-behaviour/331292 "2013-06-30T11:11:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Skribble](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@Skribble](https://forum.kirupa.com/u/Skribble)
#### Post date: [June 30, 2013, 11:11am UTC](https://forum.kirupa.com/t/cs5-5-unusual-array-behaviour/331292/1 "2013-06-30T11:11:20Z")

</div>

Hi everyone. Thanks in advance for taking the time to read my question.

_[SIZE=2]Note: All arrays are multi-dimensional.  
[/SIZE]_  
I have some code in a function, and it is meant to take an item from the **Items** array, push it to the end of the \*\*backPack \*\*array, and then assign that backPack item a new Position element from the **BPPosition** array; all items in the **Items** array have an initial Position value of 0.

The problem is that whenever I run this function, it changes the Position value of the item in the **Items** array, not just the **backPack** array like it’s meant to. I have traced the issue back to these lines of code within the function.

```auto

newitem = backPack.push(Items[itemToAdd]); //itemToAdd is a function param that is used to pass an item code
backPack[newitem-1][Position] = BPPosition[checkBP][BPPos]; // checkBP is the init of a for loop that checks for free positions in the BPPosition array

```

If I trace the **Items** array before the first line, and then after the second line, I get this:

```auto
Brick,melee,equip,A solid and heavy construction brick.,1,1,0
[2 code lines from above]
Brick,melee,equip,A solid and heavy construction brick.,1,1,1

```

As you can see, the number at the end is changed - this is the initial Position element. Why on earth would it be altering my **Items** array? I am at an absolute loss. Any and all suggestions/help would be much appreciated!

Thanks again for your time.

Brendan
