js基础数据类型

js基础数据类型有六种

  1. number:
    Number.MAX_VALUE 最大值
    Number.MIN-VALUE 最小值
    Infinity 无穷大
    -Infinity 无穷小
    NaN 非数值
    isNaN() :是数字返回false
    八进制:以0开头的 010 console.log(010)输出8,会自动转换成十进制再输出
    十六进制:以0x开头的 0xa

  2. string
    字符串转义字符(都是以反斜杠\开头):
    \n:换行 n是newline的意思
    \:反斜杠
    ':单引号
    ":双引号
    \t:缩进
    \b:空格

  3. undefined

  4. null

  5. boolean

  6. symbol(es6)

typeof 1 // ‘number’
typeof ‘1’ // ‘string’
typeof undefined // ‘undefined’
typeof true // ‘boolean’
typeof Symbol() // ‘symbol’
typeof null // ‘object’
typeof [] // ‘object’
typeof {} // ‘object’
typeof console // ‘object’
typeof console.log // ‘function’

typeof()用于检测数据类型
typeof(null)输出object,因为null是00开头,而计算机会把00开头的定义为对象,是历史遗留问题,
除了function,typeof判断引用类型都是返回Object

let arr =【1,2,3】
console.log(typeOf arr) //输出object

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值