The slice() method returns an array of a portion of the records in a grid from begin to end (end not included).
The array is a copy of the records. Modifying the array does not modify the grid records.
- begin (optional) - Zero-based index at which to begin the extraction. A negative index can be used, indicating an offset from the end of the sequence.
slice(-2)extracts the last two elements in the sequence. If
slicebegins from index
- end (optional) - Zero-based index before which to end extraction.
sliceextracts up to but not including
end. For example,
slice(1,4)extracts the second record through the fourth record (records indexed 1, 2, and 3). A negative index can be used, indicating an offset from the end of the sequence.
slice(2,-1)extracts the third record through the second-to-last record in the sequence. If
sliceextracts through the end of the sequence (
total number of records)
endis greater than the length of the sequence,
sliceextracts through the end of the sequence.