is it possible to pass a whole collection of objects as a parameter?
var col = new Array()
..build the colection
..continue with the new collection
col... and so on....
...do something with the collection col which becomes newcol
Or it is better to use a new Function() to do that?
03-18-2005, 04:53 PM
You mean like this?
Yes, you can do that. Be aware of the difference between that way of doing it and what happens if you change aCopy=.concat(aOrig).reverse(); to aCopy=aOrig.reverse();. Arrays are reference types, and copying a reference type doesn't mean the creation of an exact replica, only the copying of a reference to the same object. If you modify the array, you will change the object that references point to, unless you make sure a new object is created.
...so that I would better re-create the collection as new Object() ?
03-18-2005, 05:40 PM
Well, unless you actually want to be editing *the same* array, you need to copy it. A line like aCopy=aOrig.concat(); does just this. Beware that this makes a shallow copy and not a deep copy. If you want to create a deep copy, see my Array Functionality script.