Find a value within array of structures

Viewed 68

this might have been asked before, but didn't quite find... or what I found was old.

I have an array of structures like so:

enter image description here

Isn't there a CFML function that will allow me to check if "test@email.com" already exists under any of the structures "toAddress" ? I can obviously loop my array, check and break if found, but wondering if something already exists for this ?

Thank you. Pat

1 Answers

You can use arrayFind() with a callback function. Using your data structure above and assume the array is named myArray

if( 
    !arrayFind( myArray, function( item ){
        return item.toAddress == 'test@email.com'
    })
){
    // do stuff if address is not used.
}
Related