参考:
https://www.jb51.net/article/77140.htm
类型:string,number,boolean,object(array,object)
js中有六种数据类型,包括五种基本数据类型(Number,String,Boolean,Undefined,Null),和一种复杂数据类型(Object)
typeof的使用:
typeof 123 // "number"
typeof NaN // "number" 注意:① 涉及到的任何关于NaN的操作,都会返回NaN ② NaN不等于自身。
typeof 'abc' // "string"
typeof true // "boolean"
typeof undefined // "undefined"
typeof null // "object"
typeof { } // "object"
typeof [ ] // "object"
function a(){} // 声明一个函数
typeof a // "function"
注: typeof null ==>“object”,所以用typeof判断是否为对象,是有问题的!
null类型被当做一个空对象引用!给赋值的时候,空对象可以赋值为null!
isNaN() 函数用于检查其参数是否是非数字值。
isNaN(123) //false
isNaN('222') // false
isNaN("hello") //true