I realized that we can define variables in function in many different ways:
- as this.variableName inside function definition
- as var variableName inside function definition
- as functionName.prototype.variableName outside function definition
- as functionName.variableName outside function definition
I have put the code in the below JSFiddle and explained it in the comments. Hope this helps you.
Note: The JSFiddle may not work completely on all browsers. Better view it on Chrome or Opera.
Note: The JSFiddle may not work completely on all browsers. Better view it on Chrome or Opera.