Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[b]<cfscript>[/b]
[color gray]//define the function[/color]
[b]function isArrayElementDefined(arrayName){[/b]
[color gray]//use try{} to attempt using the array element[/color]
[b]try{[/b]
[color gray]//use the array element and return true[/color]
[b]testVar = evaluate(arrayName);
return true;[/b]
[color gray]//if using it causes an error catch it and return false[/color]
[b]}catch(any test){
return false;
}
}
</cfscript>[/b]
<cfset myArray = arrayNew(1)>
<cfset myArray[1] = "bob">
<cfset myArray[3] = "joe">
<cfoutput>
<cfloop from = "1" to = "3" index = "place">
#isArrayElementDefined("myArray[#place#]")#
</cfloop>
</cfoutput>