SOLUTION: If you think that “this” of JavaScript is the same as “this” of other programming language (Even if they sometimes act the same), I recommend reading as much as you can http://bit.ly/1nNdk8h.
Hi,
I’m reading this tutorial and I found him use “this” in this code:
The this keyword refers to the current object that is in scope. If you open the chrome developer tools en type in this in the console you get global object which is the window object.
The this keyword can be used anywhere in your code and can refer to local or global objects depending on the scope of your code.
To add, javascript has some funky scope stuff so understanding this is pretty important. To make sure that you don’t lose scope it’s not uncommon to find javascript that sets var self = this;
In a template helper, this points to the helper local context. It is a fuzzy concept, that will hopefully been replaced/improved in future versions of Meteor. To understand it, play with the following code:
It’s really awesome to see the “this” keyword appreciated! It’s a great feature.
I like to think of it as an implementation of public scope, since it’s a bound context that can be referenced outside a function, as opposed to private scope, which consists of the standard variables and arguments.