On 2008-10-14 03:06, dhtml wrote:
....
....
....
JFTR, all of these would require an additional loop to find the index of
the element with the value 3. "There's more than one way to do it"...
looks like we'll have a Javascript Golf Apocalypse soon ;-)
- Conrad
Evertjan. wrote:
>var oldArray = [4,5,6,1,2,3,4,8 ,5,9];
>var newArray = oldArray.slice( 5,10);
>newArray = newArray.concat (oldArray.slice (0,5))
>var newArray = oldArray.slice( 5,10);
>newArray = newArray.concat (oldArray.slice (0,5))
>var oldArray = [4,5,6,1,2,3,4,8 ,5,9];
>var newArray = [];
>newArray = newArray.concat (oldArray.slice (5,10),oldArray .slice(0,5))
>var newArray = [];
>newArray = newArray.concat (oldArray.slice (5,10),oldArray .slice(0,5))
var items = [4,5,6,1,2,3,4,8 ,5,9];
var newArray = items.slice(5,1 0).concat(items .slice(0,5));
var newArray = items.slice(5,1 0).concat(items .slice(0,5));
var items = [4,5,6,1,2,3,4,8 ,5,9];
var start = items.slice(5);
start.push.appl y(start, items.slice(0,5 ));
var start = items.slice(5);
start.push.appl y(start, items.slice(0,5 ));
the element with the value 3. "There's more than one way to do it"...
looks like we'll have a Javascript Golf Apocalypse soon ;-)
- Conrad
Comment