Whatever message this page gives is out now! Go check it out!
arraySome(array, function(item [,index, array]){} [, parallel] [, maxThreadCount])arrayObj.Some(callback)Parameter | Required/Optional | Description |
array | Required | Array in which at least one element is to be searched. |
callback | Required | Function to encapsulate the criteria. |
parallel | Optional | True if you want to enable parallel programming. |
maxThreadCount | Optional | The number of threads the function can execute. The number of threads must be between 1-50. If the value exceeds 50, there is an exception. |
<cfscript>
array1=[1,2,3,4,5]
isEven=(x)=>return x%2==0
writeOutput(arraySome(array1,isEven)) // Returns TRUE
</cfscript><cfscript>
myarray=[2,4,6,8,10,12,14]
isGT10=(element,index,array)=>return element>10
writeoutput(arraySome(myarray,isGT10)) // Returns True
// Using member function
writeoutput(myarray.Some(isGT10)) // Returns True
</cfscript><cfscript>
myarray=[2,5,8,1,4]
callback=function(element,index,array){
return element>10
}
result=ArraySome(array=myarray,callback=callback)
writeOutput(result) // Returns False
</cfscript><cfscript>
myarray=[2,5,8,1,4]
callback=(element,index,array)=>{
return element<10
}
result=ArraySome(array=myarray,callback=callback)
writeOutput(result) // Returns True
</cfscript><cfscript>
array1=[1,2,3,4,5]
isEven=(x)=>return x%2==0
writeOutput(array1.Some(isEven))
</cfscript><cfscript>
for(i=1;i<=10000;i++){
if(i == 4500){
arr[i]=0;
}
else
arr[i]=i*2;
}
result = arr.some(function(item){
if (item Mod 2 == 0)
return false
return true
},true,20)
writeoutput(result)
</cfscript>