mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-31 21:11:44 +02:00
Update this keyword in JavaScript roadmap (#1660)
This commit is contained in:
@@ -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>
|
||||
|
||||
|
Reference in New Issue
Block a user