Javascript Interview-JavaScript Function Call

I have started a series in which I will cover all relevant Javascript Interview topics. I already posted one article The javascript this keyword.

Today we will cover Javascript Function call, which is one of import Interview topic.

  1. Why do we use a call() Function?

So, with call(), an object can use another object method.

Let’s understand through an example.

So, you can see, this example calls the method fullName method of myName , on rameshName. Originally, rameshName has no any method fullName. But using call() function, we can access the method of another object.

Note: Even call() accepts arguments. In the above example, “demo” and “other” are the arguments.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store