a.pop() is much faster if you want to just remove the last element.

A

On Jan 24, Cortlandt Winters wrote:

> Hi Sarah,
> 
> I think you're looking for splice. (I like that name)
> 
> a.splice(5,1);
> 
> -Cort
> 
> On 1/23/06, Sarah Allen <[EMAIL PROTECTED]> wrote:
> >
> >
> > so... I thought that to remove an item from an array, I could just
> > delete it, but that appears not to work as I expected.
> >
> > This little sample program:
> > <canvas>
> > <script>
> >    var a=[0,1,2,3,4,5];
> >    Debug.write(a.length, a);
> >    delete a[5];
> >    Debug.write(a.length, a);
> > </script>
> > </canvas
> >
> > generates this output in the Debugger:
> > 6  [0, 1, 2, 3, 4, 5]
> > 6 [0, 1, 2, 3, 4, ...]
> >
> > Any one know what I should be doing here to delete an item and make the
> > array one item shorter?
> >
> > Thanks,
> > Sarah
> >
> > _______________________________________________
> > Laszlo-user mailing list
> > [email protected]
> > http://www.openlaszlo.org/mailman/listinfo/laszlo-user
> >
> 
_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user

Reply via email to