Skip to content

Commit 366d751

Browse files
committed
Finished about_this.js
1 parent e183612 commit 366d751

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

topics/about_this.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ test("'this' inside a method", function () {
44
var person = {
55
name: 'bob',
66
intro: function () {
7-
return "Hello, my name is " + this.__;
7+
return "Hello, my name is " + this.name;
88
}
99
}
1010
equal(person.intro(), "Hello, my name is bob", "If an object has a method can you access properties inside it?");
@@ -22,7 +22,7 @@ test("'this' on unattached function", function () {
2222

2323
// if the function is not called as an object property 'this' is the global context
2424
// (window in a browser). This is an example. Please do not do this in practise.
25-
window.__ = 'Peter';
25+
window.globalName = 'Peter';
2626
equal(alias(), "Hello, my name is Peter", "What does 'this' refer to when it is not part of an object?");
2727
});
2828

@@ -35,7 +35,7 @@ test("'this' set explicitly", function () {
3535
}
3636

3737
// calling a function with 'call' lets us assign 'this' explicitly
38-
var message = person.intro.call({__: "Frank"});
38+
var message = person.intro.call({name: "Frank"});
3939
equal(message, "Hello, my name is Frank", "What does 'this' refer to when you use the 'call()' method?");
4040
});
4141

0 commit comments

Comments
 (0)