...

View Full Version : "Compressing" (?) an Array



Skyzyx
09-28-2003, 02:47 AM
I can't remember for the life of me how to do this:

If you have an array:


bobbo[0]="Alpha";
bobbo[1]="Bravo";
bobbo[2]="Charlie";
etc.


You can remove one of the values by setting it to null:


bobbo[1]=null;


Then the array values will return as follows:


bobbo[0]="Alpha";
bobbo[1]=null;
bobbo[2]="Charlie";
etc.


I know there's a way to "compress" (I don't think it's called that, but I can't think of what it's called...) the array to squeeze out the null values:


bobbo[0]="Alpha";
bobbo[1]="Charlie";
etc.


Does anyone know how to do this? If so, what's it called again?

jkd
09-28-2003, 04:24 AM
Array.prototype.splice (http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/array.html#1193766)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum