Determines whether a value or expression references a function defined via a function expression, as opposed to a function statement.
isClosure(value)
Other decision functions.
Use this function to determine whether the value or expression represents a function defined via a function expression.
<cfscript> // a custom function defined via a function statement function multiplier(x,y){ return x * y; } // a custom function defined via a function expression adder = function(x,y){ return x + y; }; // a string containing the name of the function reference name = "multiplier"; </cfscript> <cfoutput> <!--- examples using function references---> <!--- a function declared via a function statement IS a custom function, but IS NOT a "closure" ---> isCustomFunction(referenceToDeclaredFunction): #isCustomFunction(multiplier)#<br> <!--- true ---> isClosure(referenceToDeclaredFunction): #isClosure(multiplier)#<br><hr> <!--- false ---> <!--- a function declared via a function expression IS NOT a custom function, but IS a "closure" ---> isCustomFunction(referenceToFunctionExpression): #isCustomFunction(adder)#<br> <!--- false ---> isClosure(referenceToFunctionExpression): #isClosure(adder)#<br><hr> <!--- true ---> <!--- examples not using function references---> <!--- a string IS NOT a custom function, nor is it a closure ---> isCustomFunction(stringContainingNameOfFunctionReference): #isCustomFunction(name)#<br> <!--- false ---> isClosure(stringContainingNameOfFunctionReference): #isClosure(name)#<br><hr> <!--- false ---> <!--- a string-literal containing the function expression variable name is not correct usage: it's just a string ---> isCustomFunction("adder"): #isCustomFunction("adder")#<br> <!--- false ---> isClosure("adder"): #isClosure("adder")#<br><hr> <!--- false ---> </cfoutput> <cfscript> // an expression can be evaluated directly result = isCustomFunction(function(x,y){ return x-y; } ); writeOutput("isCustomFunction(inlineExpression): #result#<br>"); // false result = isClosure(function(x,y){ return x-y; } ); writeOutput("isClosure(inlineExpression): #result#<br>"); // true </cfscript>