typeof操作符

转自

对一个值使用typeof操作符可能返回下列一个字符串

"undefined" : 如果这个值没有定义;
"boolean" : 如果这个值是布尔值;
"string" : 如果这个值是字符串;
"number" : 如果这个值是数值;
"object" : 如果这个值是对象或null;
"function" : 如果这个值是函数;

<html>
    <head>
    </head>                    
    <body>
    <script type="text/javascript">
        var undef;
        var str = 'abc';
        var bool = true;
        var num = 1;
        var func = function () {};
        var obj = new Object();

        alert(typeof undef); //undefinde
        alert(typeof str); //string
        alert(typeof bool); //boolean
        alert(typeof num); //number
        alert(typeof func); //function
        alert(typeof obj); //object
        alert(typeof null); //object
    </script>
    </body>
</html>
原文地址:https://www.cnblogs.com/jcbo/p/6732274.html