Tuesday, May 1, 2012

Javascript typeof() vs jQuery $.type()

Javascript typeof() vs jQuery $.type()


<!doctype html>
<head>
 <title>Mobile-Web-App: Javascript typeof() vs jQuery .type()</title>
 <meta charset="utf-8">
 <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
 <script type="text/javascript">

  $(document).ready(function(){

   var myArray = ["A", "B", "C"];
   var myEmptyArray = [];
   var myString = "ABCDEFG";
   var myEmptyString = "";
   var myInt = 1000.01;
   var myNull = null;
   
   document.writeln("<p><b>Javascript typeof()</b></p>");
   document.writeln("<p>Array: " + typeof(myArray) + "</p>");
   document.writeln("<p>Empty Array: " + typeof(myEmptyArray) + "</p>");
   document.writeln("<p>String: " + typeof(myString) + "</p>");
   document.writeln("<p>Empty String: " + typeof(myEmptyString) + "</p>");
   document.writeln("<p>Int: " + typeof(myInt) + "</p>");
   document.writeln("<p>null: " + typeof(myNull) + "</p>");
   
   document.writeln("<p><b>jQuery .type()</b></p>");
   document.writeln("<p>Array: " + $.type(myArray) + "</p>");
   document.writeln("<p>Empty Array: " + $.type(myEmptyArray) + "</p>");
   document.writeln("<p>String: " + $.type(myString) + "</p>");
   document.writeln("<p>Empty String: " + $.type(myEmptyString) + "</p>");
   document.writeln("<p>Int: " + $.type(myInt) + "</p>");
   document.writeln("<p>null: " + $.type(myNull) + "</p>");
    
  });
 </script> 
 
</head>
<body>
</body>
</html>


No comments:

Post a Comment