Skip to content

Commit ba7aa6b

Browse files
authored
Create 002-basic-data-type.md
create 002-basic-data-type.md
1 parent b0460fc commit ba7aa6b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

article/002-basic-data-type.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## JavaScript中的数据类型
2+
3+
### 1、基本数据类型
4+
5+
ECMAScript 有 5 种原始类型(primitive type),即 Undefined、Null、Boolean、Number 和 String。
6+
7+
#### typeof 运算符
8+
9+
*对变量或值调用 typeof 运算符将返回下列值之一*
10+
11+
- undefined - 如果变量是 Undefined 类型的
12+
- boolean - 如果变量是 Boolean 类型的
13+
- number - 如果变量是 Number 类型的
14+
- string - 如果变量是 String 类型的
15+
- object - 如果变量是一种引用类型或 Null 类型的
16+
17+
注释:您也许会问,为什么 typeof 运算符对于 null 值会返回 "Object"。这实际上是 JavaScript 最初实现中的一个错误,然后被 ECMAScript 沿用了。现在,null 被认为是对象的占位符,从而解释了这一矛盾,但从技术上来说,它仍然是原始值。
18+
19+
#### Number 类型
20+
21+
##### 特殊的 Number 值
22+
> 几个特殊值也被定义为 Number 类型。前两个是 Number.MAX_VALUE 和 Number.MIN_VALUE,它们定义了 Number 值集合的外边界。所有 ECMAScript 数都必须在这两个值之间。
23+
>
24+
> 事实上,有专门的值表示无穷大,(如你猜到的)即 Infinity。Number.POSITIVE_INFINITY 的值为 Infinity。Number.NEGATIVE_INFINITY 的值为 -Infinity。
25+
>
26+
> 最后一个特殊值是 NaN,表示非数(Not a Number)。NaN 是个奇怪的特殊值。
27+
28+
*NaN 也不能用于算术计算。NaN 的另一个奇特之处在于,它与自身不相等*
29+
30+
### 2、引用数据类型

0 commit comments

Comments
 (0)