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.

First-class functions

First-class functions - JavaScript Tutorial

From the course: Learning Functional Programming with JavaScript ES6+

Start my 1-month free trial

First-class functions

- [Instructor] The third major concept of functional programming is something called first-class functions. This is where things really start to get interesting and where the power and flexibility of functional programming really starts to shine through. So what exactly do we mean when we talk about first-class functions? Well, in object-oriented programming, we generally treat data and functions as different types of entities. We would probably never think of, for example, creating an array of functions or passing functions as arguments to other functions, or even stranger, returning functions from other functions. However, in functional programming, it's not only possible to do these things, it's in fact a source of tremendous flexibility. This is exactly what we mean when we say that a language supports first-class functions. It allows us to treat functions in a very similar way to how we normally treat other values such as numbers, strings, and objects. But hold on a minute…

Contents