Check the variable type

Description

jQuery has a custom .type() method for checking type:


$.type(null); // returns null
$.type([]); // returns array

Example


<!DOCTYPE html> 
<html>
<head> 
    <script src="http://yourServer.com/jQuery/jquery.min.js"></script> 
    <script> 
       console.log($.type(null)); // returns null
       console.log($.type([]));   // returns array
    </script> 
</head> <!-- w  w  w. ja v a2s  .  c om-->
<body> 
  <p>Your tags here</p>
</body> 
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Tutorial »




Basics
Selector
DOM
Event
Effect
Utilities