In this article I am going to explain about calling objects Methods
First we will decide what is the difference between method
seems that methods and function are same and technically they are in
are called without an object (Dot)
prefix will be considered as functions because they are part of global
namespace. Global functions does not require dot prefix and are owned by the
window object. We can see that isNaN(), alert() and eval () are Global
functions, they can be directly called, but we can also access it with window
object for eg. window.alert() will also work same as alert() works.
Function Call () and Apply ():-
The above function named as Call () and Apply () allows an
object to use other methods object. This
save us from having duplicates methods in several objects.
Syntax for using Call () and Apply ():
Function.call (thisArg[, arg1[, arg2[,
There are scenarios when we will be using call and apply functions;
call function is best suited when we know the argument in advance. On the other
hand apply function is used for methods when we do not know the argument and
argument list can vary.