Alex Sidorenko

A Visual Guide to Javascript for React developers - First-class functions

January 11, 2022

React is a Javascript library. There are certain concepts in Javascript that are more relevant to React development than others. This series of articles explores these concepts.

React relies on functions a lot. You may have heard that Javascript has first-class functions, but what does it mean?

A programming language is said to have First-class functions when functions in that language are treated like any other variable.
First-class function - MDN

In Javascript, we can 👇

Assign a function to a variable

Or store it in other data structures like objects and arrays.

Pass a function as an argument to another function

And then call it from the inside of this function

Return a function from another function

Note: A function that returns a function is called a Higher-Order Function.
First-class Function - MDN

Scope and Closures

These characteristics of Javascript functions allow for closures. Closures may be tricky, but understanding them gives you superpowers when working with React. We will explore closures in the coming chapters.

Articles about First-class functions