Skip to content

Commit 91e7af7

Browse files
committed
update
1 parent 5c009ba commit 91e7af7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* [01-07](https://github.com/TYRMars/JSlearn#01-07) `instanceof`
1212
* [01-08](https://github.com/TYRMars/JSlearn#01-08) `知识点小结 & 解决问题`
1313
* [02-01](https://github.com/TYRMars/JSlearn#02-01) `作用域和闭包-执行上下文`
14+
* [02-02](https://github.com/TYRMars/JSlearn#02-01) `作用域和闭包-this`
1415

1516

1617
## JS小练习
@@ -425,6 +426,25 @@ function fn(name) {
425426
}
426427
```
427428

429+
## 02-01
430+
### 作用域和闭包-this
431+
* this 要在执行时才能确认值,定义时无法确认值
432+
```JavaScript
433+
var a = {
434+
name:'A',
435+
fn:function(){
436+
console.log(this.name);
437+
}
438+
}
439+
a.fn() //this === A
440+
a.fn.call({name:'B'}) //this === {name:'B'}
441+
var fn1 = a.fn;
442+
fn1() //this === window
443+
```
444+
* 作为构造函数执行
445+
* 作为对象属性执行
446+
* 作为普通函数执行
447+
* call apply bind
428448
---
429449

430450
### JSDemo JS小程序

0 commit comments

Comments
 (0)