is there an equivalent function in CF for `array_k...
# cfml-general
s
is there an equivalent function in CF for
array_key_exists
?
b
@Scott Steinbeck Arrays don't have "keys", so I'm a little confused what you are looking for.
Or are you looking to check if a given index is defined in the array?
Generally, that would just be
Copy code
if( arr.len() >= index )
s
yes looking to see if array index exists
does the following work if the array position is a nullvalue?
b
yes, because
Copy code
arr=[nullvalue()]
dump( arr.len() )
still outputs
1
If you want to know if it's not there or null, then you can use
isNull()
Copy code
arr=[nullvalue()]

isNull( arr[1] )
isNull( arr[2] )
both of those will return
true
s
oh thats good to know
m
What about
arrayIsDefined()
? https://cfdocs.org/arrayisdefined
b
Ooh, Lucee also has an https://cfdocs.org/arrayindexexists one I'd never seen before
s
awesome, i didn’t realize that existed, thanks everyone
and look at that sweet preview 😉
🙌 1
b
In Lucee, both of those BIFs call the same thing internally. I just checked the java code
ArrayIsDefined()
just defers internally to the other function
s
good to know, and they both also return false for nulls
b
It actually depends on whether you have full null support on 🙂