File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ const PS = eval("'\u2029'");
195
195
196
196
### 语法
197
197
198
- 多参数的函数有时需要绑定其中的一个或多个函数 ,然后返回一个新函数。
198
+ 多参数的函数有时需要绑定其中的一个或多个参数 ,然后返回一个新函数。
199
199
200
200
` ` ` javascript
201
201
function add (x , y ) { return x + y; }
@@ -214,7 +214,7 @@ const add7 = x => add(x, 7);
214
214
215
215
上面两种写法都有些冗余。其中,` bind` 方法的局限更加明显,它必须提供` this ` ,并且只能从前到后一个个绑定参数,无法只绑定非头部的参数。
216
216
217
- 现在有一个[提案](https://github.com/tc39/proposal-partial-application),使用绑定参数然后返回一个新函数更加容器 。这叫做函数的部分执行(partial application)。
217
+ 现在有一个[提案](https://github.com/tc39/proposal-partial-application),使得绑定参数并返回一个新函数更加容易 。这叫做函数的部分执行(partial application)。
218
218
219
219
` ` ` javascript
220
220
const add = (x , y ) => x + y;
Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ ES5 对字符串对象提供`charAt`方法,返回字符串给定位置的字
178
178
' 𠮷' .charAt (0 ) // "\uD842"
179
179
```
180
180
181
- 上面代码中 ,` charAt ` 方法返回的是 UTF-16 编码的第一个字节,实际上是无法显示的 。
181
+ 上面代码中的第二条语句 ,` charAt ` 方法期望返回的是用2个字节表示的字符,但汉字“𠮷”占用了4个字节, ` charAt(0) ` 表示获取这4个字节中的前2个字节,很显然,这是无法正常显示的 。
182
182
183
183
目前,有一个提案,提出字符串实例的` at ` 方法,可以识别 Unicode 编号大于` 0xFFFF ` 的字符,返回正确的字符。
184
184
You can’t perform that action at this time.
0 commit comments