forked from jquery/api.jquery.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjQuery.isFunction.xml
64 lines (63 loc) · 1.9 KB
/
jQuery.isFunction.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?xml version="1.0"?>
<entry type="method" name="jQuery.isFunction" return="boolean" deprecated="3.3" removed="4.0">
<title>jQuery.isFunction()</title>
<signature>
<added>1.2</added>
<argument name="value" type="Anything">
<desc>The value to be tested.</desc>
</argument>
</signature>
<desc>Determines if its argument is callable as a function.</desc>
<longdesc>
<div class="warning">
<p>As of jQuery 3.3, <code>jQuery.isFunction()</code> has been deprecated. In most cases, its use can be replaced by <code>typeof x === "function"</code>.</p>
</div>
<p><strong>Note:</strong> As of jQuery 1.3, functions provided by the browser like <code>alert()</code> and DOM element methods like <code>getAttribute()</code> are not guaranteed to be detected as functions in browsers such as Internet Explorer.</p>
</longdesc>
<example>
<desc>Test a few parameter examples.</desc>
<code><![CDATA[
function stub() {}
var objs = [
function() {},
{ x:15, y:20 },
null,
stub,
"function"
];
jQuery.each( objs, function( i ) {
var isFunc = jQuery.isFunction( objs[ i ]);
$( "span" ).eq( i ).text( isFunc );
});
]]></code>
<css><![CDATA[
div {
color: blue;
margin: 2px;
font-size: 14px;
}
span {
color: red;
}
]]></css>
<html><![CDATA[
<div>jQuery.isFunction( objs[ 0 ] ) = <span></span></div>
<div>jQuery.isFunction( objs[ 1 ] ) = <span></span></div>
<div>jQuery.isFunction( objs[ 2 ] ) = <span></span></div>
<div>jQuery.isFunction( objs[ 3 ] ) = <span></span></div>
<div>jQuery.isFunction( objs[ 4 ] ) = <span></span></div>
]]></html>
</example>
<example>
<desc>Finds out if the parameter is a function.</desc>
<code><![CDATA[
$.isFunction(function() {});
]]></code>
<results><![CDATA[
true
]]></results>
</example>
<category slug="utilities"/>
<category slug="version/1.2"/>
<category slug="deprecated/deprecated-3.3"/>
</entry>