Being new to JavaScript, I have come across information stating that the value of this changes based on how a function is invoked. However, I am confused about when it is necessary to use this and when it is not. Some code examples I've seen utilize this, while others do not.
For example, consider this function with a for loop that does not utilize this:
var output="";
for(var i=0; i<input.length; i++) {
output = input.charAt(i) + output;
}
return output;