User Guide Cancel

IsClosure

 

Description

Determines whether a value or expression references a function defined via a function expression, as opposed to a function statement.

Returns

True, if the value represents a function expression; otherwise False.

Category

Syntax

isClosure(object)
isClosure(object)
isClosure(object)

See also

History

ColdFusion (2018 release): Introduced named parameters.

ColdFusion 10: Added this function.

Parameters

Parameter

Description

object

A value.

Usage

Use this function to determine whether the value or expression represents a function defined via a function expression.

Example

 

<cfscript>
// Non-closure
function1 = 'Hello_World';
writeoutput("Is it closure: " & isClosure(function1) & "<br>");
// Closure
function2 = function () {};
writeoutput("Is it closure: " & isClosure(function2));
</cfscript>
<cfscript> // Non-closure function1 = 'Hello_World'; writeoutput("Is it closure: " & isClosure(function1) & "<br>"); // Closure function2 = function () {}; writeoutput("Is it closure: " & isClosure(function2)); </cfscript>
<cfscript>
// Non-closure
function1 = 'Hello_World';
writeoutput("Is it closure: " & isClosure(function1) & "<br>");

// Closure
function2 = function () {};
writeoutput("Is it closure: " & isClosure(function2));
</cfscript>

Output

Is it closure: NO
Is it closure: YES

Get help faster and easier

New user?