Hi All,

Hope you all are doing fine . IN todays tutorial we will look into one important higher order function in JavaScript which will help you allot for scripting in ServiceNow.

Lets first understand what is Higher order function in JavaScript.

Higher order function :
In JavaScript, functions can be assigned to variables in the same way that strings or arrays can. They can be passed into other functions as parameters or returned from them as well.

A “higher-order function” is a function that accepts functions as parameters and/or returns a function.


Lets now understand the function Reduce in JavaScript :
The .reduce() method iterates through an array and returns a single value.

It takes a callback function with two parameters (accumulator, The .reduce() method iterates through an array and returns a single value.

It takes a callback function with two parameters (accumulator, currentValue) as arguments. On each iteration, accumulator is the value returned by the last iteration, and the currentValue is the current element. Optionally, a second argument can be passed which acts as the initial value of the accumulator.

Here, the .reduce() method will sum all the elements of the array.) as arguments. On each iteration, accumulator is the value returned by the last iteration, and the currentValue is the current element. Optionally, a second argument can be passed which acts as the initial value of the accumulator.

Here, the .reduce() method will sum all the elements of the array.

Hope you like this video. If yes then please like follow subscribe to my channel Technomonk

Regards,
Amit Gujarathi
(Team Technomonk)

technomonkadmin

View all posts

Add comment

Your email address will not be published. Required fields are marked *