js to determine whether a data type is an array type, judge whether it is a string type, determine whether it is a numeric type, and so on, this article has several good examples where you can learn
1 Determines whether the array type 2 determines whether the string type 3 determines whether the value type 4 determines whether the date type 5 Determines whether it is a function of 6 to determine whether the object is the 1 to determine whether the array Type code is as follows: <script type= "Text/javascript" > //<! [cdata[ var a=[0]; document.write (IsArray (a), ' <br/> '); function IsArray (obj) { return ( typeof obj== ' object ') &&obj.constructor==Array; } //]]> </script> 2 Determine if the string type code is as follows: <script type= "Text/javascript" > //<! [cdata[ document.write (isstring (' Test '), ' <br/> '); document.write (isstring, ' <br/> '); function isstring (str) { return (typeof str== ' string ') &&str.constructor==String; } // ]]> </script> 3 to determine whether the numeric type code is as follows: <script type= "Text/javascript" > //<! [cdata[ document.write (isnumber (' Test '), ' <br/> '); document.write (isnumber, ' <br/> '); function Isnumber (obj) { return (typeof obj== ' number ') &&obj.constructor==Number; } //]]> </script> 4 Determine if the date type code is as follows: <script type= "Text/javascript" > //<! [cdata[ document.write (isDate (new Date), ' <br/> '); document.write (IsDate (a), ' <br/> '); function isDate (obj) { return (typeof obj== ' object ') &&obj.constructor==Date; } //] > </script> 5 to determine whether the function code is as follows: <script type= "Text/javascript" > //< ! [cdata[ document.write (isfunction (function test () {}), ' <br/> '); document.write (Isfunction (10), ' <br/> '); function isfunction (obj) { return (typeof obj== ' function ') &&obj.constructor== function; } //]]> </script> 6 to determine whether the object code is as follows: <script type= "text/ JavaScript "> //<! [cdata[ document.write (IsObject (new Object), ' <br/> '); document.write (IsObject (10),' <br/> '); function IsObject (obj) { return (typeof obj== ' object ') &&obj.constructor==Object; } //]]> </script>