Skip to content

Bookmarked https://gomakethings.com/the-early-return-pattern-in-javascript/. My favorite programming trick. > With …

Bookmarked https://gomakethings.com/the-early-return-pattern-in-javascript/.

My favorite programming trick.

With the early return pattern, you check for the opposite of the thing you want, and return early to end the function when that’s the case.

This reduces nested if statements, and makes your code a bit easier to read.

The early return pattern in JavaScript
gomakethings.com