Update this keyword in JavaScript roadmap (#1660)
parent
3fc4bcac31
commit
c738a2844c
1 changed files with 14 additions and 1 deletions
@ -1 +1,14 @@ |
||||
# Javascript this keyword |
||||
# This Keyword |
||||
|
||||
In JavaScript, the `this` keyword is a little different compared to other languages. It refers to an object, but it depends on how or where its being invoked. It also has some differences between strict mode and non-strict mode. |
||||
|
||||
- In an object method, `this` refers to the object |
||||
- Alone, `this` refers to the global object |
||||
- In a function, `this` refers to the global object |
||||
- In a function, in strict mode, `this` is undefined |
||||
- In an event, `this` refers to the element that received the event |
||||
- Methods like call(), apply(), and bind() can refer `this` to any object |
||||
|
||||
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://www.w3schools.com/js/js_this.asp'>The JavaScript `this` Keyword</BadgeLink> |
||||
<BadgeLink colorScheme='yellow' badgeText='Read' href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this'>This Keyword</BadgeLink> |
||||
|
||||
|
Loading…
Reference in new issue