Shany  Jenkins

Shany Jenkins

1620709380

Why You Need to Know About First-Class Functions in JavaScript

First off, let me make something clear. This article will have nothing to do with first-class seats on an airplane. Instead, today we’re going over first-class functions in JavaScript, which is something that every Javascript Developer needs to know as it is fundamental in understanding other concepts such as callbacks and higher-order functions.

What are First-class functions?

First-class functions can be found in a multitude of languages like Python, Scala, Haskell, and of course, JavaScript. Essentially, first-class functions are functions that can be treated like any other variable. To be considered a first-class function, a function must be able to do the following:

  1. Assigned to a variable
  2. Passed into a function as an argument
  3. Returned by a function

Now we’re going to check to see if functions in JavaScript fulfill all these criteria needed to be first-class functions.

#javascript

Why You Need to Know About First-Class Functions in JavaScript