TypeOf(x)
Last updated August 16, 2002
Version: 3 | Requires: CF5 | Library: DataManipulationLib
Description:
Enhanced typeof() function with added checking for binary, custom function, and date values.
Return Values:
Returns a string.
Example:
<cfscript>
function foo() { return; }
foo2 = createDate( 2002, 4, 1 );
foo3 = Tobinary( ToBase64( "foo" ) );
</cfscript>
<cfoutput>
#typeof( foo )#<br>
#typeof( foo2 )#<br>
#typeof( foo3 )#<br>
</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
x | The data to inspect. | Yes |
Full UDF Source:
/**
* Returns the type of the variable.
* Made it cf5/mx compat with use of getFunctionList
*
* @param x The data to inspect. (Required)
* @return Returns a string.
* @author Jordan Clark (JordanClark@Telus.net)
* @version 3, August 16, 2002
*/
function TypeOf(x) {
if(isArray(x)) return "array";
if(isStruct(x)) return "structure";
if(isQuery(x)) return "query";
if(isSimpleValue(x) and isWddx(x)) return "wddx";
if(isBinary(x)) return "binary";
if(isCustomFunction(x)) return "custom function";
if(isDate(x)) return "date";
if(isNumeric(x)) return "numeric";
if(isBoolean(x)) return "boolean";
if( listFindNoCase( structKeyList( GetFunctionList() ), "isXMLDoc" ) AND
isXMLDoc(x)) return "xml";
if(isSimpleValue(x)) return "string";
return "unknown";
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016