javascript method

I am instantiating a series of objects - when clicked, i want to add them to an array. I think the best way to do this is to have a main script attached to the camera with the array. the objects will call that script and add themselves to that array?

can anyone help with this, im using javascript. is this the way to do this? ive been having a lot of trouble getting the 2 scripts to communicate.

If there is only going to one array per scene, you can make it static and therefore eliminate the need for a direct reference to the script. If you need multiple, but a set amount of arrays per scene, you could use jagged(MyArray) or multidim(MyArray[,]) arrays.
If you need multiple arrays and the number of arrays is subject to change, than you can make the arrays as needed in a static function. If none of these options will work, then there is always GameObject.Find(), although I would not recommend this as it is a very slow process.