Skip to content

Commit c7d1d87

Browse files
committed
update
1 parent 91e7af7 commit c7d1d87

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,38 @@ fn1() //this === window
445445
* 作为对象属性执行
446446
* 作为普通函数执行
447447
* call apply bind
448+
```JavaScript
449+
function Foo(name){
450+
this.name = name;
451+
}
452+
var f = new Foo('zhangsan');
453+
454+
var obj = {
455+
name:'A',
456+
printName:function(){
457+
console.log(this.name);
458+
}
459+
}
460+
obj.printName()
461+
462+
function fn(){
463+
console.log(this);
464+
}
465+
fn()
466+
467+
// call apply bind
468+
function fn1(name) {
469+
alert(name);
470+
console.log(this);
471+
}
472+
fn1.call({x:100},'zhangsan',20);
473+
// bind
474+
var fn2 = function fn2(name) {
475+
alert(name);
476+
console.log(this);
477+
}.bind({y:200});
478+
fn2('zhangsan',20);
479+
```
448480
---
449481

450482
### JSDemo JS小程序

0 commit comments

Comments
 (0)