Higher Order Function

A function that operates on functions, either by taking one as an argument or by returning one.

React hooks are examples of higher order functions:

1
2
3
4
5
6
7
8

useEffect(() => {
  const timeout = setTimeout(() => alert('Hello!'), 1000);
  
  return () => {
    clearTimeout(timeout);
  };
}, []);

Other examples include map, reduce, and filter:

1
2
3
4
5
collection.map((item) => ... );

collection.reduce((item) => ... );

collection.filter((item) => ... );

Further Reading