Skip to content

Commit e906dd7

Browse files
authored
Fixes to question 77
1 parent 570f2df commit e906dd7

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

zh-CN/README-zh_CN.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,19 +2401,13 @@ function sum(a, b) {
24012401
<details><summary><b>答案</b></summary>
24022402
<p>
24032403

2404-
#### 答案: B
2405-
2406-
纯函数一种若输入参数相同,则永远会得到相同输出的函数。
2407-
2408-
在特定情况下,即使输入相同参数,也不能得到相同的返回值:
2404+
#### 答案: A
24092405

2410-
<pre>
2411-
var a = b = {}
2412-
a[Symbol.toPrimitive] = b[Symbol.toPrimitive] = () => Math.random()
2413-
sum(a, b) // Uncertain
2414-
</pre>
2406+
纯函数在相同的输入值时,需产生相同的输出,其输出的结果,与输入值以外的其他隐藏信息或状态无关,也和由I/O设备产生的外部输出无关。
2407+
纯函数不会产生副作用。
24152408

2416-
所以它不是一个纯函数。
2409+
纯函数与副作用的定义可参考:
2410+
https://zh.wikipedia.org/wiki/%E5%89%AF%E4%BD%9C%E7%94%A8_(%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%A7%91%E5%AD%A6)
24172411

24182412
</p>
24192413
</details>
@@ -5085,4 +5079,4 @@ if (!typeof randomValue === "string") {
50855079
`!typeof randomValue === "string"` 总是返回false,因为我们实际上是在执行 `false === "string"`。因为条件返回的是 `false`,所以 `else` 语句中的代码块会被运行,因此打印 `Yay it's a string!`
50865080
50875081
</p>
5088-
</details>
5082+
</details>

0 commit comments

Comments
 (0)