1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="utf-8"> 5 <title>jQuery.isFunction demo</title> 6 <style> 7 div { 8 color: blue; 9 margin: 2px; 10 font-size: 14px; 11 } 12 span { 13 color: red; 14 } 15 </style> 16 <script src="https://code.jquery.com/jquery-1.10.2.js"></script> 17 </head> 18 <body> 19 20 <div>jQuery.isFunction( objs[ 0 ] ) = <span></span></div> 21 <div>jQuery.isFunction( objs[ 1 ] ) = <span></span></div> 22 <div>jQuery.isFunction( objs[ 2 ] ) = <span></span></div> 23 <div>jQuery.isFunction( objs[ 3 ] ) = <span></span></div> 24 <div>jQuery.isFunction( objs[ 4 ] ) = <span></span></div> 25 26 <script> 27 function stub() {} 28 var objs = [ 29 function() {}, 30 { x:15, y:20 }, 31 null, 32 stub, 33 "function" 34 ]; 35 36 jQuery.each( objs, function( i ) { 37 var isFunc = jQuery.isFunction( objs[ i ]); 38 $( "span" ).eq( i ).text( isFunc ); 39 }); 40 </script> 41 42 </body> 43 </html>
1 jQuery.isFunction( objs[ 0 ] ) = true 2 jQuery.isFunction( objs[ 1 ] ) = false 3 jQuery.isFunction( objs[ 2 ] ) = false 4 jQuery.isFunction( objs[ 3 ] ) = true 5 jQuery.isFunction( objs[ 4 ] ) = false
Description: Determine if the argument passed is a JavaScript function object.