array.length read only? workaround?

hello guys. Is there anyway of changing array.length through script?

I am basically trying to make a backup var for a array. The length of the array may change with deferent situations.

also I need something that works in javascript.


As Eric mentionned. Javascript Array will initialize new element the first time you reference them, so no need to worry about size/length.

As for built-in, I usually use something like this:

var myStrings:String[] = new String[9];
function AddString(str:String){
    var buffer:String[] = myStrings;
    myStrings = new String[buffer.length+1];
    for(i=0;i<buffer.length;i++){ myStrings _= buffer*; }*_
 _*myStrings[myStrings.length-1] = str;*_

You change the length of the array by creating a new one and copying the values over. (There's a Resize function for built-in arrays, but it only works directly in C#, and even then what it actually does is create a new array anyway.) If you're talking about the Javascript-specific Array class, you can add or remove elements.