js基础数据类型有六种
-
number:
Number.MAX_VALUE 最大值
Number.MIN-VALUE 最小值
Infinity 无穷大
-Infinity 无穷小
NaN 非数值
isNaN() :是数字返回false
八进制:以0开头的 010 console.log(010)输出8,会自动转换成十进制再输出
十六进制:以0x开头的 0xa -
string
字符串转义字符(都是以反斜杠\开头):
\n:换行 n是newline的意思
\:反斜杠
':单引号
":双引号
\t:缩进
\b:空格 -
undefined
-
null
-
boolean
-
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