reduce

Executes a callback function for every single item in the array and returns the accumulated result. Iterates the items left to right.

Parameters

callback Function

The function that will be executed for every item.

Returns

Number—The accumulated result.

Example - working with reduce method

 <script>
  var arr = new kendo.data.ObservableArray([100, 10, 20, 30]); 

  var result = arr.reduce((totalCount, item) => totalCount - item)
  /* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(arr)
  console.log(result)
</script>
In this article