'this' keyword, not clear
I get confused about ' this ' keyword in the following codes, there are two 'this': var Foo = function(string){ this.name=string // 1st-this } Foo.prototype.get_name = function(){ return this.name // 2nd-this } var myFoo = new Foo('John') the_name=myFoo.get_name() ' the_name ' is equal to 'John', the prototype method get the name by return this.name . But can anyone explain to me the 1st- this and 2nd- this , what do they stand for? In Javascript, the value of this is dependent on the way you call the function . There are 5 ways to call a function in JS, and they all have effect on this : new