For example. Say you have an array of 5 entries. They are all strings by the
way.
myArray = ("entry0","entry1","entry2","entry3","entry4");
What is needed is a mechanism/function to move any of the array entries up
or down in the array. I have been trying by first splice(selectedEntry) out
of the Array, then a couple of slice() and then concat() them all back
together but this seems very clumsy.
Does anyone know of a more elegant way to accomplish this?
Regards,
David J.
<script type="text/javascript">
var arr = [0,1,2,3];
var tmp = arr.splice(3,1);
arr.splice(2,0,tmp);
alert(arr); // 0,1,3,2
</script>
IMHO you are seeking for List functionality rather than for Array's
one. See for instance
<http://groups.google.com/group/comp.lang.javascript/msg/19ac11e0164d8ab4>
as well as the whole thread which contains a valuable criticism.
You $add() method is so cool !!
As indicated at the top of the linked post, the coolest (IMHO) part
with splice-zero was suggested by poster signing as "Ray".
Thank you, that is a very effecient way to do it...
David J.
Despite the poor implementation?
Mike
Please quote when replying to posts in this group.