Skip to content

Commit 31f70c2

Browse files
author
YuChengKai
committed
fix bug
1 parent a1f44c7 commit 31f70c2

File tree

5 files changed

+41
-16
lines changed

5 files changed

+41
-16
lines changed

JS/JS-ch.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,24 @@ let a = {
126126
}
127127
```
128128

129+
当然你也可以重写 `Symbol.toPrimitive` ,该方法在转基本类型时调用优先级最高。
130+
131+
```js
132+
let a = {
133+
valueOf() {
134+
return 0;
135+
},
136+
toString() {
137+
return '1';
138+
},
139+
[Symbol.toPrimitive]() {
140+
return 2;
141+
}
142+
}
143+
1 + a // => 3
144+
'1' + a // => '12'
145+
```
146+
129147
## 四则运算符
130148

131149
只有当加法运算时,其中一方是字符串类型,就会把另一个也转为字符串类型。其他运算只要其中一方是数字,那么另一方就转为数字。并且加法运算会触发三种类型转换:将值转换为原始值,转换为数字,转换为字符串。
@@ -153,8 +171,6 @@ let a = {
153171

154172
上图中的 `toPrimitive` 就是对象转基本类型。
155173

156-
一般推荐使用 `===` 判断两个值,但是你如果想知道一个值是不是 `null` ,你可以通过 `xx == null` 来比较。
157-
158174
这里来解析一道题目 `[] == ![] // -> true` ,下面是这个表达式为何为 `true` 的步骤
159175

160176
```js
@@ -1471,16 +1487,16 @@ parseFloat((0.1 + 0.2).toFixed(10))
14711487
14721488
## 字符简写
14731489
1474-
| 简写 | 作用 |
1475-
| :--: | :------------------------: |
1476-
| \w | 匹配字母数字或下划线或汉字 |
1477-
| \W | 和上面相反 |
1478-
| \s | 匹配任意的空白符 |
1479-
| \S | 和上面相反 |
1480-
| \d | 匹配数字 |
1481-
| \D | 和上面相反 |
1482-
| \b | 匹配单词的开始或结束 |
1483-
| \B | 和上面相反 |
1490+
| 简写 | 作用 |
1491+
| :--: | :------------------: |
1492+
| \w | 匹配字母数字或下划线 |
1493+
| \W | 和上面相反 |
1494+
| \s | 匹配任意的空白符 |
1495+
| \S | 和上面相反 |
1496+
| \d | 匹配数字 |
1497+
| \D | 和上面相反 |
1498+
| \b | 匹配单词的开始或结束 |
1499+
| \B | 和上面相反 |
14841500
14851501
# V8 下的垃圾回收机制
14861502

JS/JS-en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ parseFloat((0.1 + 0.2).toFixed(10))
13891389
13901390
| shorthand | Effect |
13911391
| :--: | :------------------------: |
1392-
| \w | alphanumeric characters, underline character or Chinese characters |
1392+
| \w | alphanumeric characters, underline character |
13931393
| \W | the opposite of the above |
13941394
| \s | any blank character |
13951395
| \S | the opposite of the above |

Network/Network-zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ HTTP 2.0 中所有加强性能的核心点在于此。在之前的 HTTP 版本
450450

451451
## 服务端 Push
452452

453-
在 HTTP 2.0 中,服务端可以在客户端不请求的情况下主动推送资源
453+
在 HTTP 2.0 中,服务端可以在客户端某个请求后,主动推送其他资源
454454

455455
可以想象以下情况,某些资源客户端是一定会请求的,这时就可以采取服务端 push 的技术,提前给客户端推送必要的资源,这样就可以相对减少一点延迟时间。当然在浏览器兼容的情况下你也可以使用 prefetch 。
456456

Network/Network_en.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ When talking about the header of TCP, these fields are significant:
9696

9797
## State machine
9898

99-
HTTP is stateless, so TCP which is based on HTTP is also stateless. It seems like that TCP links two ends, client and server, but it is actually that both these two ends maintain the state together:
99+
HTTP is stateless, so TCP which is under the HTTP is also stateless. It seems like that TCP links two ends, client and server, but it is actually that both these two ends maintain the state together:
100100
![](https://user-gold-cdn.xitu.io/2018/5/1/1631bef9e3c60035?w=1280&h=965&f=png&s=101432)
101101

102102
The state machine of TCP is very complicated, and it is closely related to the handshake of opening and closing a connection. Now we'll talk something about these two kinds of handshake.
@@ -450,7 +450,9 @@ In HTTP 2.0, the header of the transport is encoded using the HPACK compression
450450

451451
## Server push
452452

453-
In HTTP/2, the server can push resources to the client without the client having to request. Imagine that, something in the server is necessary to the client, so the server can push the associated resources ahead of time to reduce the delay time. By the way, we can also use `pre-fetch` if the client is compatible.
453+
In HTTP/2, the server can actively push other resources after a request from the client.
454+
455+
Imagine that, something in the server is necessary to the client, so the server can push the associated resources ahead of time to reduce the delay time. By the way, we can also use `pre-fetch` if the client is compatible.
454456

455457
## QUIC
456458

log-zh.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## 2018-07-23
2+
3+
- 对象转基本类型中增加 `Symbol.toPrimitive` 的描述
4+
- 修正正则简写中对 `\w` 错误的描述
5+
- 修改网络模块中的翻译错误
6+
- 删除判断 `null` 的语句
7+
- 修改服务端推送中的内容,使描述更加严谨

0 commit comments

Comments
 (0)