Var and this in the class, Private Methods


No error, I just want to know what is the difference between "var returnBalance = function() {
return bankBalance;" and "this.returnBalance = function() {
return bankBalance;

Replace this line with your code.


You can't use the keyword this when creating a function notation. I don't really know how to explain why, but this is a word that refers to itself basically, and it refers to it's parameters.
The main difference is that

will create a function, and

will not.

This is a very nice explanation of the this keyword.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.