1.基本数据类型:String、Number、Boolean、undefined、null
2.引用数据类型:Object、Array、Date、RegExp、Function
检测基本类型用typeof
检测引用类型用instanceof
var u;
typeof "hello world"; //string
typeof 22; //number
typeof true; //boolean
typeof u; //undefined
typeof null; //object
引用类型用typeof都是object
var now = new Date();
var x = {};
var y = function(){};
now instanceof Date; //true
[] instanceof Array; //true
x instanceof Object //true
y instanceof Function // true
网友评论