Created
April 10, 2011 19:52
-
-
Save dalmaer/912660 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the code of the "foo" function | |
// never changes, but the "this" value | |
// differs in every activation | |
function foo() { | |
alert(this); | |
} | |
// caller activates "foo" (callee) and | |
// provides "this" for the callee | |
foo(); // global object | |
foo.prototype.constructor(); // foo.prototype | |
var bar = { | |
baz: foo | |
}; | |
bar.baz(); // bar | |
(bar.baz)(); // also bar | |
(bar.baz = bar.baz)(); // but here is global object | |
(bar.baz, bar.baz)(); // also global object | |
(false || bar.baz)(); // also global object | |
var otherFoo = bar.baz; | |
otherFoo(); // again global object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment