Skip to content

Commit b2877ad

Browse files
committed
Merge branch 'gh-pages' of github.com:ruanyf/es6tutorial into gh-pages
2 parents f847132 + ad08ffe commit b2877ad

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

docs/array.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ Array.prototype.copyWithin(target, start = 0, end = this.length)
515515

516516
它接受三个参数。
517517

518-
- target(必需):从该位置开始替换数据。
518+
- target(必需):从该位置开始替换数据。如果为负值,表示倒数。
519519
- start(可选):从该位置开始读取数据,默认为 0。如果为负值,表示倒数。
520520
- end(可选):到该位置前停止读取数据,默认等于数组长度。如果为负值,表示倒数。
521521

@@ -583,6 +583,16 @@ i32a.copyWithin(0, 2);
583583

584584
这两个方法都可以接受第二个参数,用来绑定回调函数的`this`对象。
585585

586+
```javascript
587+
function f(v){
588+
return v > this.age;
589+
}
590+
let person = {name: 'John', age: 20};
591+
[10, 12, 26, 15].find(f, person); // 26
592+
```
593+
594+
上面的代码中,`find`函数接收了第二个参数`person`对象,回调函数中的`this`对象指向`person`对象。
595+
586596
另外,这两个方法都可以发现`NaN`,弥补了数组的`indexOf`方法的不足。
587597

588598
```javascript

docs/decorator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function log(target, name, descriptor) {
200200
var oldValue = descriptor.value;
201201

202202
descriptor.value = function() {
203-
console.log(`Calling "${name}" with`, arguments);
203+
console.log(`Calling ${name} with`, arguments);
204204
return oldValue.apply(null, arguments);
205205
};
206206

0 commit comments

Comments
 (0)