To find first element of array matching a boolean condition in JavaScript, we use the find
method.
For instance, we write
const result = someArray.find(isNotNullNorUndefined);
to call someArray.find
with the isNotNullNorUndefined
function which returns the boolean condition we’re looking for.
The first item with the condition if it’s found.