jQuery Data Type How to - Check is a value a function








Question

We would like to know how to check is a value a function.

Answer


<!--from w  w w.j a va2s.c  o m-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){
               function stub() {}
               console.log($.isFunction(stub) );
        });
    </script>
  </head>
</html>

The code above is rendered as follows: