您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

typeof返回的数据类型有哪些

2024/6/25 11:09:18发布24次查看
typeof返回的数据类型有6种,分别为:1、object,对象类型;2、undefined,未定义类型;3、string,字符串类型;4、number,数字类型;5、boolean,布尔类型;6、function,函数类型。
typeof 共返回6种数据格式:
1、object                     --对象类型的变量或值,或者null(这个是js历史遗留问题,将null作为object类型处理)
2、undefined              --未定义的变量或值
3、string                     --字符串类型的变量或值
4、number                  --数字类型的变量或值
5、boolean                 --布尔类型的变量或值
6、function                 --函数类型的变量或值
示例:
undefined
var a1; typeof(a1);
运行结果:
number
var num1=12; typeof(num1);
运行结果:
string
var num2="12"; typeof(num2);
运行结果:
boolean
var flag=true; typeof(flag);
运行结果:
object
var str=new string();typeof(str);var a=null; typeof(a);
运行结果:
function
var fn = function(){};typeof(fn); typeof(class c{});
运行结果:
更多编程相关知识,请访问:编程入门!!
以上就是typeof返回的数据类型有哪些的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product