Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Comment:
Migrated to Confluence 5.3
Excerpt |
---|
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.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
var returnValue = obj.isFunction; |
Return value
Value | Type | Notes | API Version |
---|---|---|---|
true | Boolean | The object is a function | 1.0 |
false | Boolean | The object is not a function | 1.0 |
Examples
Pre-check that a value is not null before using .isFunction...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
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 } |
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
Availability
Requires:
|
Div | ||||
---|---|---|---|---|
| ||||
ContentsJump to:
|
Div | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Type CheckingTopics:
|