How to get class data from another script?

Hi I have an array of classes and I was woundering how do I access that from another script? Heres an example:

How do I get script 2’s class 1 in the array to match the one in script 1?

Script1.js

    class Class1{
    	var number : int;
    }
    
    var objects1 : Class1[];

Script2.js

    class Class2{
    	var number : int;
    }
    
    var objects2 : Class2[];
    
    function GetObjects(){
    	//...
    }

all of this inside Script2.js …

var myPointerToScript1 : Script1;
myPointerToScript1 = GetComponent( Script1 );
var sameAsTheOtherArray:Class1[]
sameAsTheOtherArray = myPointerToScript1. objects1;
// you're done!
sameAsTheOtherArray is now the same thing as objects1

for example sameAsTheOtherArray[4] and objects1[4] are the same thing.

Don’t forget Script1 is a Class. Script2 is also a Class.

Don’t forget the definitions for Class1 and Class2 could be anywhere. (It might be clearer if you put them in the same script, or somewhere else altogether.)

Hopefully I understand you, and that helps !

here’s a SIMPLER EXAMPLE:

Script1.js
var xxx:int;

Script2.js
var s1 = GetComponent(Script1);
Debug.Log( "the value of x in the other script is " + s1.x );

this may help you more generally