TypeScript Array reduce() - TypeScript

What is TypeScript - Array reduce()?

reduce() method applies a function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value.

Syntax

Parameter Details

  • callback − Function to execute on each value in the array.
  • initialValue − Object to use as the first argument to the first call of the callback.

Return Value

Returns the reduced single value of the array.

Example

On compiling, it will generate the same code in JavaScript.

Its output is as follows −

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

TypeScript Topics