ArrayEvery(array, callback)
arrayObj.Every(callback)
Parameter |
Required/Optional |
Description |
array |
Required |
Array in which all elements are to be searched. |
callback |
Required |
Function that encapsulates |
<cfscript> array1=[1,2,3,4,5] isEven=(x)=>return x%2==0 writeOutput(arrayEvery(array1,isEven)) // Returns False </cfscript>
<cfscript> arrayAllEven=[2,4,6,8,10,12,14] isEven=(x)=>return x%2==0 writeOutput(arrayEvery(arrayAllEven,isEven)) // Returns True </cfscript>
<cfscript> myarray=[2,4,6,8,10,12,14] isGT10=(element,index,array)=>return element>10 writeoutput(arrayEvery(myarray,isGT10)) // Returns True writeoutput(myarray.Every(isGT10)) // Returns False </cfscript>
<cfscript> myarray=[2,5,8,1,4] callback=function(element,index,array){ return element<10 } result=ArrayEvery(array=myarray,callback=callback) writeOutput(result) // Returns True </cfscript>
<cfscript> myarray=[2,5,8,1,4,12,29] callback=(element,index,array)=>{ return element>10 } result=ArrayEvery(array=myarray,callback=callback) writeOutput(result) // Returns False </cfscript>
<cfscript> array1=[1,2,3,4,5] isEven=(x)=>return x%2==0 writeOutput(array1.Every(isEven)) </cfscript>