It’s 2023, Time to Replace All Your Regular Functions with Arrow Functions

Richard Oliver Bray
5 min readJun 6, 2023
Panicked child looking at camera. Image from lexia.art

Arrow functions were introduced in ECMAScript 6 (ES6 or ES2015) as a new, shorter way to write function expressions. However, it’s important to note that arrow functions are NOT a replacement for regular functions.

It’s not April 1st but the title of this article is a joke. I saw a similar post a while back and thought I’d make a play on it for the clicks 😁

It can be frustrating to see some new programmers or bootcamp graduates believe that regular functions old and that arrow functions are the new way of writing functions. Lambda or arrow functions exist in many programming languages, but that doesn’t mean they replace all functions with them.

While arrow functions are a great and necessary addition to JavaScript, it’s important to understand how they differ from regular functions and when to use each type of function.

NOTE: There are many more differences than the one in this article but I’m only going to go through a few of them.

Also if you like short form videos, you can watch a summary of this article on TikTok.

Before we begin

Let’s start off by explaining some terminology.

This is a function declaration:

function add(a, b) {
return a + b;
}

This is a function expression:

const add = function(a, b) {
return a + b;
}

And this is an arrow function expression

const add = (a, b) => {
return a + b;
}

1. Hoisting

Function declarations are hoisted, which means they can be called before they are declared. This is useful mainly for organising code. I usually place the main function at the top of the file and helper functions at the bottom (or in a different file if I have loads of helpers).

console.log(add(1, 2)); // 3

function add(a, b) {
return a + b;
}

You can see in the example above, the add function is called above it is declared.

Arrow functions, on the other hand, are not hoisted. This means that they must be declared before they can be…

--

--

Richard Oliver Bray

Co-founder of orva.studio. Building digital products and teaching others to do the same. Saved by grace.