You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: questions/explain-how-this-works-in-javascript/en-US.mdx
+1-1
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ title: Explain how `this` works in JavaScript
6
6
7
7
There's no simple explanation for `this`; it is one of the most confusing concepts in JavaScript because it's behavior differs from many other programming languages. The one-liner explanation of the `this` keyword is that it is a dynamic reference to the context in which a function is executed.
8
8
9
-
A longer explanation follows is that `this` follows these rules:
9
+
A longer explanation is that `this` follows these rules:
10
10
11
11
1. If the `new` keyword is used when calling the function, meaning the function was used as a function constructor, the `this` inside the function is the newly-created object instance.
12
12
2. If `this` is used in a `class``constructor`, the `this` inside the `constructor` is the newly-created object instance.
0 commit comments