-
Notifications
You must be signed in to change notification settings - Fork 0
/
14.js
47 lines (38 loc) · 1.04 KB
/
14.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//这里只能用var定义变量,let,const定义的变量,不是绑定在window下。
var str = 'window';
const obj = {
str:'obj',
nativeFn: function(){
console.log(this.str, '当前词法作用域中的this');
return function(){
console.log('原生函数',this.str);
}
},
arrowFn: function(){
console.log(this.str, '当前词法作用域中的this');
return ()=>{
console.log('箭头函数',this.str);
}
}
};
const obj2 = {
str:'obj2'
}
let aaa = obj.nativeFn()
let bbb = obj.arrowFn()
// console.log('函数调用二 **********');
// nativeFn.call(obj2);
// arrowFn.call(obj2);
// console.log('函数调用三 **********');
// setTimeout(function(){
// nativeFn();
// arrowFn();
// },50);
// //函数调用四
// var doc = document.documentElement;
// doc.str = 'document';
// doc.addEventListener('click',function(){
// console.log('函数调用四 **********');
// },false);
// doc.addEventListener('click',nativeFn,false);
// doc.addEventListener('click',arrowFn,false);