r/javascript • • Feb 23 '13

Common JavaScript "Gotchas"

https://github.com/stevekwan/best-practices/blob/master/javascript/gotchas.md
16 Upvotes

50 comments sorted by

View all comments

Show parent comments

0

u/mirion Feb 23 '13

This. Definitely this.

2

u/rabidcow Feb 23 '13

Sure, you could use this:

(function(){
    this.foo = 'foo';
})();

2

u/mirion Feb 23 '13

Sigh. I should know better than to use the word 'this' in a javascript thread.

1

u/[deleted] Feb 24 '13

You should know better than to use the word 'this' in any thread. There's an up arrrow button next to the post that does that.