Languages
[Edit]
EN

JavaScript - find first element of array matching boolean condition

0 points
Created by:
lena
714

In this article, we would like to show you how to find the first element of an array matching boolean condition using JavaScript.

Practical example

Edit

In this example, we use find() method with passed isDefined() function to find the first element that is defined (that's not null or undefined).

Note:

The find() method has been introduced in ES6.

 

References

Edit
  1. Array.prototype.find() - JavaScript | MDN
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join