Returns a one-level deep copy of a portion of an array. Equivalent of Array.prototype.slice. The result of the slice method is not an instance of ObvservableArray. It is a regular JavaScript Array object.

Important: The slice method does not modify the original ObservableArray.


begin Number

Zero-based index at which to begin extraction.

end Number

Zero-based index at which to end extraction. If end is omitted, slice extracts to the end of the sequence.

Example - slice items from an ObservableArray

var array = new[1, 2, 3]);
var firstAndSecond = array.slice(0, 2);
console.log(firstAndSecond); // outputs [1, 2]
In this article
Not finding the help you need?