Ryli Dunlap
Dec 11, 2023

Not sure if they're used as much these days, but many libraries like jQuery had implementations of 'forEach' behavior before 'forEach' was supported by newer browsers. jQuery has a .each() function with an implementation that supports breaking out of loops early by returning false. This was a source of confusion for me when I switched from using jQuery to the native 'forEach' in newer versions of JavaScript, as the implementation is not the same regarding 'falsey' return values.

https://api.jquery.com/jQuery.each/

From the docs: "We can break the $.each() loop at a particular iteration by making the callback function return false. Returning non-false is the same as a continue statement in a for loop; it will skip immediately to the next iteration."

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Ryli Dunlap
Ryli Dunlap

Written by Ryli Dunlap

Aspiring writer. Recovering programmer. Many opinions — some unpopular. I unload them here. Blog: https://pontifi.co Dance/Music: https://rylito.com

No responses yet

Write a response