How can I create a new array that contains all elements numbered nth to (n+k)th from an old array?
5 Answers
You want the slice method.
var newArray = oldArray.slice(n, n+k);
1 Comment
Quentin
While W3Schools doesn't appear to have any errors on that page (which is unusual), I think the MDC documentation is better: developer.mozilla.org/en/Core_JavaScript_1.5_Reference/…