First-class higher-order functions

The term first class means that the language itself treats functions as values; they can be passed around as example arguments to other functions. A higher-order function is a function that takes other functions as parameters. Let's look at an example to make this clearer:

function project(obj, fn) {  return fn(obj);}project( { name : 'chris', age: 37 }, (obj) => obj['name'] ); // 'chris'project({ name : 'chris', age: 37 }, (obj) => obj['age'] ) // 37 

Here we can see that the second argument in our project() function is a function. The function is being applied to the first argument. We can also see that, depending on what input argument we give the higher-order function as its second argument, the higher-order ...

Get Architecting Angular Applications with Redux, RxJS, and NgRx now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.