基本数据类型
JavaStript识别的这6种类型为基本类型,基础类型或元类型。如下:
含义 | 说明 |
---|---|
var a = 1,b = '2',c = true,d,e = null,f = function(){}
typeof a === 'number'; // true
typeof b === 'string'; // true
typeof c === 'boolean'; // true
typeof d === 'undefined'; // true
typeof e === 'object'; // true
typeof f === 'function'; // true
注意:
typeof [] === 'object' //true
typeof [] === 'Array' //false
[] instanceof Array // true