1
0
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:
Jozias Martini
2022-09-01 20:08:03 -03:00
committed by GitHub
parent 3fc4bcac31
commit c738a2844c

View File

@@ -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>