Skip to content

Commit

Permalink
update: 数据类型
Browse files Browse the repository at this point in the history
  • Loading branch information
qianguyihao committed Mar 23, 2022
1 parent b24621d commit 8e6e6b9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions 01-HTML/05-HTML标签:字体标签和超链接.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ publish: true
### 特殊字符(转义字符)

- ` `:空格 (non-breaking spacing,不断打空格)
- `<`:小于号(less than)
- `>`:大于号(greater than)
- `&lt;`:小于号`<`(less than)
- `&gt;`:大于号`>`(greater than)
- `&amp;`:符号`&`
- `&quot;`:双引号
- `&apos;`:单引号
Expand Down
7 changes: 5 additions & 2 deletions 04-JavaScript基础/07-基本数据类型:Number.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
title: 07-基本数据类型:Number
publish: true
---

<ArticleTopAd></ArticleTopAd>
Expand Down Expand Up @@ -45,7 +44,9 @@ number

### NaN

**NaN**:是一个特殊的数字,表示 Not a Number,非数值。比如:
**NaN**:是一个特殊的数字,表示 Not a Number,非数值。在进行数值运算时,如果得不到正常结果,就会返回 NaN。

比如:

```javascript
console.log('abc' / 18); //结果是NaN
Expand Down Expand Up @@ -131,6 +132,8 @@ console.log(a);

虽然程序可以对`-``*``/`、`%``这几个符号自动进行“隐式转换”;但作为程序员,我们最好自己完成转换,方便程序的可读性。

关于隐式转换的详细内容,可以看后续的文章《JavaScript基础/typeof和数据类型转换》。

## 浮点数的运算

### 运算精度问题
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cosole.log(typeof myObj); // 打印结果:object

- Null 类型的值只有一个,就是 null。比如 `let a = null`

- 使用 typeof 检查一个 null 值时,会返回 object。
- 从语义上讲,null表示一个空对象,所以使用 typeof 检查一个 null 值时,会返回 object。

## undefined:未定义类型

Expand Down Expand Up @@ -101,7 +101,7 @@ foo();

## 其他区别

null 和 undefined 有很大的相似性。看看 `null == undefined` 的结果为 `true` 也更加能说明这点
undefined 实际上是由 null 衍生出来的,所以`null == undefined`的结果为 true。

但是 `null === undefined` 的结果是 false。它们虽然相似,但还是有区别的,其中一个区别是,和数字运算时:

Expand Down
2 changes: 1 addition & 1 deletion 04-JavaScript基础/09-typeof和数据类型转换.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ parseFloat() 的几个特性,可以参照 parseInt()。

**重中之重来了:**

转换为 Boolean 的上面这几种情况,**很重要**开发中会经常用到。比如说,我们在项目开发中,经常需要对一些**非布尔值**做逻辑判断,符合条件后,才做选一步的事情。这个逻辑判断就是依据上面的四种情况。
转换为 Boolean 的上面这几种情况,**极其重要**开发中会频繁用到。比如说,我们在项目开发中,经常需要对一些**非布尔值**做逻辑判断,符合条件后,才做下一步的事情。这个逻辑判断就是依据上面的四种情况。

举例:(接口返回的内容不为空,前端才做进一步的事情)

Expand Down

0 comments on commit 8e6e6b9

Please sign in to comment.