(info) This AI is still in early stages of development.

object.isFunction

A quick way to check if an object is a function...

 

Syntax

The .isFunction property is added to all objects, but only returns true on functions.

var returnValue = obj.isFunction;

Return value

ValueTypeNotesAPI Version
trueBooleanThe object is a function1.0
falseBooleanThe object is not a function1.0

Examples

Pre-check that a value is not null before using .isFunction...

var val = null;
 
if (val.isFunction) { // Reference Error (null.isFunction not defined)
}
 
if (val && val.isFunction) { // false
	// val is a function
}
 
// alternate approach using typeOf()
if (typeOf(val) == "function") { // false
	// val is a function
}
Availability STABLE

Requires:

Contents

Jump to:

Type Checking

Topics:

  • classOf() — Returns the name of the class (constructor) used to create an object...
  • object.isFunction — A quick way to check if an object is a function...
  • typeOf() — Returns a more accurate object type name than Javascript's native "typeof https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/typeof" operator...
  • object.isArray — A quick way to check if an object is an array...

Â