类型
在js中,有6种不同的数据类型:
- string
- number
- boolean
- object
- function
- symbol
3种对象类型:
- Object
- Date
- Array
2种不包含任何值的数据类型
- null
- undefined
typeof
typeof操作符可以返回string, number, boolean, object, function, undefined
特殊地,null的数据类型是object
Object.prototype
1 | var arr = [1,2,3] |
由于js中只有3种对象类型,Object.prototype.toString.call只会返回上述三种结果之一。