Im curious when it is needed/best practice to use the keyword this
. I understand that this
is used when determining a functions this
value but is it always needed?
The reason I am asking is because I have a internal function and it is called within my module and all it really does is sort some data you pass it. My question is should I call this function using the this
keyword or stand alone.
E.g:
function formatSomeData(data){
//code........
}
this.formatSomeData(data);
OR
formatSomeData(data);
I get that the context of where the function is being called and what its purpose is matters in answering the question, but in this case like I mentioned, I really don't need to access the this
object at any point. Is it still good practice to use it when calling functions?
What I'm asking is not so much as to how "this" works, but when is it appropriate to use it and when isn't it.