//typeof操作符
var box="cai";
alert(typeof box);
alert(typeof'cai');
//Undefined类型
var box;
alert(box);
//Null类型
var box = null;
alert(typeof box); //返回object类型
alert(undefined==null); //返回true,undefined是派生自null的
var box;
var car = null;
alert(typeof box==typeof car); //返回false
//Boolean类型
var box = true;
alert(typeof box); //返回boolean类型
var hello = "Hello World";
var hello2 = Boolean(hello); //强制转换,还有一种隐式转换,出现在if语句。
alert(hello2); //返回true
alert(typeof hello2); //返回boolean类型
JavaScript:数据类型
最新推荐文章于 2024-05-17 15:36:25 发布