Today I have come across two ways of calling an object method.
This I have seen in a kind of API which when expose certain functions to the external world. In those methods I have found following way obj.MyFn.apply(obj, arguments) to call the encapsulated methods which they dont want to expose to the outside world.
So my question is:
What is the difference(context here is in terms of encapsulation of API's internal methods, here its MyFn) between following two ways of calling a method of an object?
- obj.MyFn() and
- obj.MyFn.apply(obj, arguments);
Assumption: I have an object obj having defined a method named as MyFn.