doc: create a comparision section
This commit is contained in:
1 parent
043e2255d6
commit
8f43853f81
1 file changed
+18
@@ -97,3 +97,21 @@ skittle.addEventListener("dblclick", () => {
|
|||||||
id("result").textContent = ":O You ate a skittle...";
|
id("result").textContent = ":O You ate a skittle...";
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 用this比较不同的回调函数
|
||||||
|
```javascript
|
||||||
|
function init() {
|
||||||
|
// this === 窗口
|
||||||
|
id("btn1").addEventListener("click", namedFunction)l
|
||||||
|
id("btn2").addEventListener("click", function() {
|
||||||
|
console.log("this === " + this); // this === #btn2
|
||||||
|
});
|
||||||
|
id("btn3").addEventListener("click", () => {
|
||||||
|
console.log("this === " + this); // this === 窗口
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function namedFunction() {
|
||||||
|
console.log("this === " + this); // this === #btn1
|
||||||
|
}
|
||||||
|
```
|
||||||
Reference in new issue
Block a user