Skip to content

Commit 7469129

Browse files
committed
Merge pull request BonsaiDen#252 from jasonbellamy/master
Added information about using bind in ECMAScript 5.
2 parents 137a76b + d004276 commit 7469129

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

doc/en/function/this.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ local variable inside of `method` that refers to `Foo`.
8383
outer `this`. In combination with [closures](#function.closures), it can also
8484
be used to pass `this` values around.
8585

86+
As of ECMAScript 5 you can use the `bind` method combined with an anonymous function to achieve the same result.
87+
88+
Foo.method = function() {
89+
var test = function() {
90+
// this now refers to Foo
91+
}.bind(this);
92+
test();
93+
}
94+
8695
### Assigning Methods
8796

8897
Another thing that does **not** work in JavaScript is function aliasing, which is

0 commit comments

Comments
 (0)