欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

JS的typeof返回哪些数据类型?

程序员文章站 2022-06-04 22:00:01
...
<script>
    console.log(typeof 123);             //number
    console.log(typeof '123');           //string
    console.log(typeof function);        //报错 function是关键字
    console.log(typeof string);          //undefined
    console.log(typeof undefined);       //undefined
    console.log(typeof null);            //object 较为特殊
    console.log(typeof isNaN);           //function 是个判断函数
    console.log(typeof isNaN(123));      //boolean
    console.log(typeof []);              // object 数组也是对象
    console.log(Array.isArray);          //ƒ isArray() { [native code] }
    console.log(Array.isArray());        //false
    console.log(toString.call([]));      //[object Array]
    console.log([].constructor);         //ƒ Array() { [native code] }
</script>

总结一哈:number,string,boolean,underfind,object,function;

相关标签: 个人笔记