unshift
Adds one or more items to the beginning of an ObservableArray and returns the new length. An equivalent of Array.prototype.unshift.
The
unshiftmethod raises thechangeevent. Theactionfield of the event argument is set to"add". Theitemsfield 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 that will be added 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);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(result); // outputs "4"
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(array); // outputs [0, 1, 2, 3]
</script>In this article