Mark As Completed Discussion

Built-in higher-order functions:

Numerous in-built JavaScript operations on arrays, DOM methods, strings, promise methods, and so on are higher-order functions that offer substantial abstraction. Here are some of the several built-in higher-order functions:

  • Array.prototype.map(): The map() method generates a new array by invoking the callback function given as a parameter for each input array element. The map() method takes each value returned by the callback function and uses these values to form a new array.
  • Array.prototype.reduce(): The reduction method applies the callback function to each element of the calling array, resulting in a single output value. The reduce method uses two arguments: the reducer function and the optional initialValue. A single value is returned after applying the reducer to each array element.
  • EventTarget.addEventListener(): When called on an EventTarget, the addEventListener() function adds the given listener to that target. An event-supporting object, such as an Element inside a document, a window, or another event-supporting object, can serve as the event target (like XMLHttpRequest).
  • Array.prototype.filter(): The filter() method generates a shallow duplicate of a piece of an array, filtered to include only the array elements that satisfy the provided function's test.
  • Array.prototype.forEach(): The forEach method in JavaScript is a function that loops over an array, calling a specified callback function at each iteration. The forEach method is fully browser and node supported, as forEach was incorporated in the ECMAScript 5 specification.