javascript判断数据类型

<DOCTYPE html>
<html>
  <head>
    <title>判断数据类型</title>
  </head>
  <body>
    <script>
         var obj={
            name:'张三',
            age:18,
            kill:['javascript','HTML5','CSS3','VUE'],
            web:{
                HTML:'超文本标记语言',
                    JS:{
                        name:'javascript'
                    }
            },
            say:function(){
               
            }
         }
         
         for(var i in obj){
            var str=Object.prototype.toString.call(obj[i]); 
            var type=str.substring(8,str.length-1)
            console.log(i+''+type+'类型')
         }
    </script>
  </body>
</html>

 

posted @ 2018-12-19 10:52  (⊙o⊙)买噶  阅读(124)  评论(0编辑  收藏  举报