Splicing Arrays

var week = ["sun", "Mon", "Tue", "Wed", "thur", "Fri", "sat"]; var weekdays = week.slice(1,6);

You can carve arrays the same way you can strings by using the .splice(start, end) method and specifying the starting index and the ending index. The items in the array beginning with the start index until the item just before the end index are returned in a new array object. All indexes are zero based.

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.