tags:

views:

51

answers:

2

How can I create a new array that contains all elements numbered nth to (n+k)th from an old array?

+4  A: 

You want the slice method.

var newArray = oldArray.slice(n, n+k);
Bob
While W3Schools doesn't appear to have any errors on that page (which is unusual), I think the MDC documentation is better: https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/slice
David Dorward
A: 

i think the slice method will do what you want.

arrayObject.slice(start,end)
Eric