JavaScript 数据类型

var box;
alert(typeof box);//box是Undefined类型,值是undefined,类型返回的字符串是undefined

var box = true;
alert(typeof box);//box是Boolean类型,值是true,类型返回的字符串是boolean

var box = '姓名';
alert(typeof box);//box是String类型,值是'姓名',类型返回的字符串是string

var box = 250;
alert(typeof box);//box是Number类型,值是250,类型返回的字符串是number

//空的对象,表示这个对象创建了,里面没有东西
//空对象,表示没有创建,就是一个null

var box = {};
alert(typeof box);//box是Object类型,值是[object Object],类型返回的字符串是object

ver box = null;
alert(typeof box);//box是Null类型,值是null,类型返回的字符串是object

var box = new Object();
alert(typeof box);//box是Object类型,值是[object Object],类型返回的字符串是object

alert(undefined == null); //他们都是空的,所以相等理所当然

posted @ 2017-04-26 15:17  vxee  阅读(107)  评论(0编辑  收藏  举报