Well, you could do it an alternate way.
You could add a generic function to the Array object, for deleting items correctly.. 
i.e. deleting an item and redistributing the array by moving the adjacent items down a 
step.
Something like:

Array.prototype.deleteItem=function(item){ 
 for(var i=0,n=0;i<this.length;i++){  
  if(this[i]!=this[item]) this[n++]=this[i]  
 } 
 this.length=this.length-1  
}

/////////////////////////////////

var a=[1,2,3,4,5]
alert(a +"  "+a.length)
a.deleteItem(2)
alert(a +"  "+a.length)


Some extra work is needed for accociative arrays.. but this is a great way of 
extending Array functionality, and keeping functions dealing with "lists" and "stacks" 
general.

/ Bart

-----Ursprungligt meddelande-----
Fr�n: Scott Andrew LePera <[EMAIL PROTECTED]>
Till: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Datum: den 14 december 2000 20:24
�mne: Re: [Dynapi-Dev] deleteFromArray


>> hmm, so a delete array[element]  will leave a gap instead of removing the
>> element and move all "higher" elements down one step ?
>
>Yes, Brandon is correct in this.  That's one of the reasons why
>removeFromArray was created in the first place.  It keeps ordinal arrays
>in the correct order when you remove an element.
>
>-- 
>scott andrew lepera
>-----------------------------------
>web stuff:     www.scottandrew.com
>music stuff:   www.walkingbirds.com
>_______________________________________________
>Dynapi-Dev mailing list
>[EMAIL PROTECTED]
>http://lists.sourceforge.net/mailman/listinfo/dynapi-dev

_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/mailman/listinfo/dynapi-dev

Reply via email to