From the course: Learning Functional Programming with JavaScript ES6+

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Higher-order functions

Higher-order functions - JavaScript Tutorial

From the course: Learning Functional Programming with JavaScript ES6+

Start my 1-month free trial

Higher-order functions

- [Instructor] We've spent quite a bit of time in previous videos talking about first-class functions in JavaScript. We've seen how JavaScript treats functions in much the same way as strings, numbers, objects and arrays. And how this allows us to do things, like pass functions as arguments to other functions and return functions from other functions. Now, there's a term for functions that either take other functions as arguments or return functions. We call them higher-order functions. Using them in our code can provide amazing flexibility and re usability. To demonstrate this fact, we're going to look at some examples of higher-order functions and what they can do. The first thing we're going to use higher-order functions to solve, is the problem of checking arguments in JavaScript. It happens quite often in programming that we want to make sure our arguments meet certain criteria. We might want to make sure that our arguments are the correct types, for example or we might want to…

Contents