# Copy/duplicate array! (Concat and slice not working!)

**URL:** <https://forum.kirupa.com/t/copy-duplicate-array-concat-and-slice-not-working/306218>\
**Category:** flash\
**Created:** [March 11, 2010, 10:03am UTC](https://forum.kirupa.com/t/copy-duplicate-array-concat-and-slice-not-working/306218 "2010-03-11T10:03:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarMel](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@MarMel](https://forum.kirupa.com/u/MarMel)\
**Post date:** [March 11, 2010, 10:03am UTC](https://forum.kirupa.com/t/copy-duplicate-array-concat-and-slice-not-working/306218/1 "2010-03-11T10:03:29Z")

</div>

Heey guys!

I’m working on programming some sort of weekagenda. I built this week from arrays. You have an arrayWeek, with in it arrayMonday (being arrayWeek[0]), arrayTuesday (arrayWeek[1]), …, arraySunday (being arrayWeek[6])… All days are arrays themselves, they all contain different ‘temps’ (as i called them)… So you can have arrayWeek[3][2], being the third ‘temp’ of thursday. All this is in the class Program. Well, I hope you understand what I mean!

Now, I want to be able to copy a day. So at some point I want tuesday to be the same as monday, but when altering monday afterwards, tuesday has to stay the same (not be altered like monday)… I searched Kirupa and found [http://www.kirupa.com/developer/actionscript/tricks/arrayduplication.htm](http://www.kirupa.com/forum/../developer/actionscript/tricks/arrayduplication.htm), but it didn’t work! Still, the other day also is changed when changing the first one!

Here’s (part of) my code:

```auto

program.arrayWeek[dayNumber] = []; //emptying the array first
for(var j:Number = 0; j < program.arrayWeek[asDayNumber].length; j++){
program.arrayWeek[dayNumber][j] = program.arrayWeek[asDayNumber][j].concat();
}

```

“dayNumber” is the current day, the one that has to change. “adDayNumber” is the day currentDay has to be the same to…

I also tried the same without the forloop and [j] part, so trying to copy the whole day at once… Also no result!

De copying itself works, but they stay referenced to the same array… Maybe there is a workaround the concat and slice functions?

Thanks!  
MarMel
