分类
基本类型
String: 任意字符串
Number:任意数字
boolean: true/false
undefined: undefined
null:null
对象(引用)类型
Object: 任意对象
Function:一种特别的对象(可以执行)
Array:一种特别的对象(数值下标,内部数据是有序的)
判断
- typeof
- 可以判断: undefined/ 数值/ 字符串/ boolean/ function
- 不能判断: null 与 object, object与array
- instanceof: 判断对象的具体类型
- ===
- 可以判断: undefined, null
// 1. 基本(重点)
// typeof返回数据类型的字符串表达!!!,判断时需要加''
var a
console.log(a, typeof a, typeof a === 'undefined', a===undefined)
a=null
console.log(typeof a, a===null)