@@ -15,7 +15,7 @@ When using `this` in global scope, it will simply refer to the *global* object.
15
15
16
16
foo();
17
17
18
- Here ` this ` will again refer to the * global* object.
18
+ Here, ` this ` will again refer to the * global* object.
19
19
20
20
> ** ES5 Note:** In strict mode, the global case ** no longer** exists.
21
21
> ` this ` will instead have the value of ` undefined ` in that case.
@@ -24,14 +24,14 @@ Here `this` will again refer to the *global* object.
24
24
25
25
test.foo();
26
26
27
- In this example ` this ` will refer to ` test ` .
27
+ In this example, ` this ` will refer to ` test ` .
28
28
29
29
### Calling a Constructor
30
30
31
31
new foo();
32
32
33
33
A function call that is preceded by the ` new ` keyword acts as
34
- a [ constructor] ( #function.constructors ) . Inside the function ` this ` will refer
34
+ a [ constructor] ( #function.constructors ) . Inside the function, ` this ` will refer
35
35
to a * newly created* ` Object ` .
36
36
37
37
### Explicit Setting of ` this `
@@ -56,7 +56,7 @@ inside of `foo` will be set to `bar`.
56
56
### Common Pitfalls
57
57
58
58
While most of these cases make sense, the first one is to be considered another
59
- mis-design of the language, as it ** never** has any practical use.
59
+ mis-design of the language because it ** never** has any practical use.
60
60
61
61
Foo.method = function() {
62
62
function test() {
@@ -65,10 +65,10 @@ mis-design of the language, as it **never** has any practical use.
65
65
test();
66
66
}
67
67
68
- A common misconception is that ` this ` inside of ` test ` refers to ` Foo ` , while in
69
- fact it ** does not** .
68
+ A common misconception is that ` this ` inside of ` test ` refers to ` Foo ` ; while in
69
+ fact, it ** does not** .
70
70
71
- In order to gain access to ` Foo ` from within ` test ` it is necessary to create a
71
+ In order to gain access to ` Foo ` from within ` test ` , it is necessary to create a
72
72
local variable inside of ` method ` which refers to ` Foo ` .
73
73
74
74
Foo.method = function() {
@@ -85,17 +85,17 @@ be used to pass `this` values around.
85
85
86
86
### Assigning Methods
87
87
88
- Another thing that does ** not** work in JavaScript is function aliasing, that is,
88
+ Another thing that does ** not** work in JavaScript is function aliasing, which is
89
89
** assigning** a method to a variable.
90
90
91
91
var test = someObject.methodTest;
92
92
test();
93
93
94
- Due to the first case ` test ` now acts like a plain function call; therefore,
94
+ Due to the first case, ` test ` now acts like a plain function call; therefore,
95
95
` this ` inside it will no longer refer to ` someObject ` .
96
96
97
- While the late binding of ` this ` might seem like a bad idea at first, it is in
98
- fact what makes [ prototypal inheritance] ( #object.prototype ) work.
97
+ While the late binding of ` this ` might seem like a bad idea at first, in
98
+ fact, it is what makes [ prototypal inheritance] ( #object.prototype ) work.
99
99
100
100
function Foo() {}
101
101
Foo.prototype.method = function() {};
0 commit comments