Copy values from one object (scriptwise) to another

Hey guys, this might be a simple question but I couldnt find any related posts or questions.
What I want to do is to make a script object the copy of another one. I’m trying to do this this way:

    public var test : List.<Objects>;
    public var localTest : List.<Objects>;
    
    function OnEnable(){
          localTest = test;
    }

Apparently this only sends a reference to the first object, thus everything I do with the second one is actually happening to the first one. I am afraid that if i loop through the first one and add the values to the second one, it will also only save references to the first one.

Any help is much appreciated

Once a List is created, it references the values from different memory locations. Eg. if you create an integer list then list[0], list[1]…etc actually points the value at that memory location, not the actual value. The instruction localtest = test actually passes the data of those memory locations to another list. So, what will happen, is when you edit the localtest list, it will automatically reflect in test list as well.

So, you need to create a new list and copy all elements in a loop as

for( int i = 0; i < test.count; i++ )
{
    localtest.Add(test*);*

}