Skip to content

Commit 9e2f8d1

Browse files
committedDec 8, 2017
this keyword - and done.
1 parent f9a8c26 commit 9e2f8d1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

‎Answers.md

+6
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,9 @@ function doSomething() {
4545

4646
The compiler must go 'up' one layer in Scope to find the declaration of thing in order to achieve Closure.
4747

48+
## 4. Four rules of the `this` keyword
49+
50+
1. When a function is contained in the Global Scope, `this` refers to Global/console/window.
51+
2. When a function is called with a preceeding dot, the object before the dot is `this`.
52+
3. When a Constructor Function is used, `this` refers to the Specific Instance of the object created.
53+
4. When `.call` or `.apply` are used, `this` is explicitly defined.

0 commit comments

Comments
 (0)
Please sign in to comment.