From the course: Learning Functional Programming with JavaScript ES6+

Unlock the full course today

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

Returning functions

Returning functions - JavaScript Tutorial

From the course: Learning Functional Programming with JavaScript ES6+

Start my 1-month free trial

Returning functions

- [Narrator] So far, we've seen that's it's possible to define functions in pretty much the same way we define other things, such as strings or numbers, and we've also seen that it's possible to pass functions as arguments, again, similar to other types. So the next logical thing for us to look at with respect to first-class functions is our ability to return functions from other functions. Now the usefulness of first-class functions has been kind of limited up until now, without this final piece of our first-class functions puzzle. This is the place where the flexibility that first-class functions give us really starts to shine through. So first let's try to wrap our heads around the concept of functions and return functions. In programming, it's common to hear functions referred to as a black box. You put data into the box, you get some different data out. If we're talking about a function called double for example, we'd put one number the box, say five, and we'd get another number…

Contents