122
rated 0 times
[
123]
[
1]
/ answers: 1 / hits: 175415
/ 15 Years ago, sun, march 14, 2010, 12:00:00
Say, I have an array that looks like this:
var playlist = [
{artist:Herbie Hancock, title:Thrust},
{artist:Lalo Schifrin, title:Shifting Gears},
{artist:Faze-O, title:Riding High}
];
How can I move an element to another position?
I want to move for example, {artist:Lalo Schifrin, title:Shifting Gears}
to the end.
I tried using splice, like this:
var tmp = playlist.splice(2,1);
playlist.splice(2,0,tmp);
But it doesn't work.
More From » arrays