【WEB前端-基础】JS 9种数据类型 最新

概览

最新的 ECMAScript 标准定义了 9 种数据类型:

  • 6 种原始类型,使用 typeof 运算符检查:
    • undefinedtypeof instance === "undefined"
    • Booleantypeof instance ==="boolean"
    • Numbertypeof instance === "number"
    • Stringypeof instance === "string"
    • BigInttypeof instance === "bigint"
    • Symboltypeof instance === "symbol"
  • nulltypeof instance === "object"
  • Objecttypeof instance === "object"。任何 constructed 对象实例的特殊非数据结构类型,也用做数据结构:new Objectnew Arraynew Mapnew Setnew WeakMapnew WeakSetnew Date,和几乎所有通过 new keyword 创建的东西。
  • Function:非数据结构,尽管 typeof 操作的结果是:typeof instance === "function"。这个结果是为 Function 的一个特殊缩写,尽管每个 Function 构造器都由 Object 构造器派生。

typeof 操作符

检测给定变量的数据类型

var message = "ABBE";
alert(typeof message);
alert(typeof(message));
alert(typeof 95);

在这里插入图片描述

5种基础数据类型

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值