Javascript call() Method.

The call() function is a predefined JavaScript function. The call() allows for a function belonging to object can use a method belonging to another object.

var person = {
fullName: function() {
return this.firstName + " " + this.lastName;
var person1 = {
lastName: "gupta"
var person2 = {
lastName: "sharma"
}; // Will return "rahul gupta"

This example calls the fullName function of person.

call() method provides a new value of this. Through call() method, you can write a function once and then inherit it in another object, without having to rewrite the function for the new object.

Originally published at