Keep the original array unchanged while manipulating a copy of it - Forum

Forum Navigation
You need to log in to create posts and topics.

Keep the original array unchanged while manipulating a copy of it

How do I keep the original array unchanged while manipulating a copy of it?

CreateArray [orginalArray] 1,2,3,4,5,6

SetVar [copyArray] [orginalArray]

setvar [copyArray(0)] 9

ConsoleLog [orginalArray]
ConsoleLog [copyArray]

By changing the copyArray the original also changed how should I avoid this?

Hi @asmat,

CreateArray [orginalArray] 1,2,3,4,5,6
ArrayCopy [orginalArray] 0 6 [copyArray]

setvar [copyArray(0)] 9
ConsoleLog [orginalArray]
ConsoleLog [copyArray]

This work

 

luishp and asmat have reacted to this post.
luishpasmat
Open chat
1
Do you need more info?
Hi, do you have any doubt?