This article is mainly to determine the JavaScript data type (sample code) for a detailed introduction, the need for friends can come to the reference, I hope to help you.
&NBSP;1 determines whether the array type code is as follows: <strong><script type= "Text/javascript" > //<! [cdata[ var a=[0]; document.write (IsArray (a), ' <br/> '); function IsArray (obj) { return ( typeof obj== ' object ') &&obj.constructor==Array; } //]]> </script></STRONG> 2 to 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 Determines 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 judgment isNo is the date type code 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 determine if 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 Determines whether the object code is as follows: <script type= "Text/javascript" > LineNum//<! [cdata[ document.write (IsObject (new Object), ' <br/> '); document.write (IsObject), ' <br/ > '); function IsObject (obj) { return (typeof obj== ' object ') &&obj.constructor==Object; } //]]> </SCRipt>