无力挽回 2星
共回答了231个问题采纳率:94.6% 评论
基本数据类型有:数字(number),字符串(string),布尔(boolean),NULL和undefined
检测方法使用js的typeof类型进行数据类型判断,返回的对象分别是:
1:数字的返回类型是Number,判断条件是为:typeof 需要判断的数字 == Number,则表示这个数是一个数字类型;
2:字符串的返回类型是String,注意这里所有返回的值是一个字符串,并且首字母大写;
3:布尔返回的类型是Boolean,表示数据的真假
4:Null的返回类型是Object,所以这里判断null对象则不能使用typeof进行判断,需要用instance of条件进行判断
5:undefined返回类型是undefined,表示变量未定义。
1小时前
思韵枫 2星
共回答了230个问题 评论
对象为object 了解js的都知道, 有个typeof 用来判断各种数据类型,有两种写法:typeof xxx ,typeof(xxx) 如下实例:
typeof 2 输出 number typeof null 输出 object typeof {} 输出 object typeof [] 输出 object typeof (function(){}) 输出 function typeof undefined 输出 undefined typeof '222' 输出 string typeof true 输出 boolean 这里面包含了js里面的五种数据类型 number string boolean undefined object和函数类型 function
21小时前
猜你喜欢的问题
53分钟前1个回答
1小时前1个回答
47分钟前1个回答
1小时前3个回答
1小时前1个回答
52分钟前1个回答
热门问题推荐
3个月前1个回答
2个月前1个回答
3个月前1个回答
2个月前3个回答
3个月前1个回答
2个月前3个回答
前天 1个回答
1个月前1个回答
2个月前4个回答