I am looking at code that looks like
this.f.call(this);
Or in some other cases
this.someObj.f.call(this.someObj);
Is there any difference between them and
this.f(); this.someObj.f();
Are there any circumstances under which the behavior will be different? (For example, the behavior is different if this or someObj is null or is not actually an object, or f is not really a function? I cannot think of a way, an exception, and the other is not, but maybe I missed something. ..)
EDIT: To clarify: yes, I know that .call can be used to indicate the value of this that the function sees, and can be useful in cases where you cannot use the obj.f() syntax because f not an obj property or you donβt know if it is). My question is not how .call works at all. My question is about this case, when I do not see the obvious reason for using .call , and not the object-property syntax.
source share