Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 1-js/05-data-types/12-json/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ alert( JSON.stringify(meetup, *!*['title', 'participants', 'place', 'name', 'num

该函数会为每个 `(key,value)` 对调用并返回“已替换”的值,该值将替换原有的值。如果值被跳过了,则为 `undefined`。

在我们的例子中,我们可以为 `occupiedBy` 以外的所有内容按原样返回 `value`。为了 `occupiedBy`,下面的代码返回 `undefined`:
在我们的例子中,我们可以为 `occupiedBy` 以外的所有内容按原样返回 `value`。对于 `occupiedBy`,下面的代码返回 `undefined`:

```js run
let room = {
Expand Down
4 changes: 2 additions & 2 deletions 1-js/06-advanced-functions/10-bind/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ alert( triple(5) ); // = mul(3, 5) = 15

## 在没有上下文情况下的 partial

当我们想绑定一些参数(arguments),但是这里没有上下文 `this`,应该怎么办?例如,对于一个对象方法。
当我们想绑定一些参数(arguments),但是不想绑定上下文 `this`,应该怎么办?例如,对于一个对象方法。

原生的 `bind` 不允许这种情况。我们不可以省略上下文直接跳到参数(arguments)。

Expand Down Expand Up @@ -319,7 +319,7 @@ user.sayNow("Hello");

## 总结

方法 `func.bind(context, ...args)` 返回函数 `func` 的“绑定的(bound)变体”,它绑定了上下文 `this` 和第一个参数(如果给定了)
方法 `func.bind(context, ...args)` 返回函数 `func` 的“绑定的(bound)变体”,它绑定了上下文 `this` 和 `...args` 参数

通常我们应用 `bind` 来绑定对象方法的 `this`,这样我们就可以把它们传递到其他地方使用。例如,传递给 `setTimeout`。

Expand Down