unshift

Adds one or more items to the beginning of an ObservableArray and returns the new length. Equivalent of Array.prototype.unshift.

Important: The unshift method raises the change event. The action field of the event argument is set to "add". The items field of the event argument is an array that contains the new items.

Returns

Number the new length of the array.

Parameters

item1, ..., itemN

The items to add to the beginning of the ObservableArray.

Example - add items to the beginning of an ObservableArray

<script>
var array = new kendo.data.ObservableArray([2, 3]);
var result = array.unshift(0, 1);
console.log(result); // outputs "4"
console.log(array); // outputs [0, 1, 2, 3]
</script>
In this article
Not finding the help you need?