Computer Science, asked by davidgurung2775, 1 year ago

What is a JavaScript call() Method?

Answers

Answered by NiksDwivedi
0

\huge\bold{Answer}

_______________________________

________________________________

What is a JavaScript call() Method?

»»» The call() method in javascript is the predefined method.

»»» It can be used to invoke (call) a method with an owner object as a parameter.

»»» With call(), an object can use a method belonging to another object.

_________________________________

\bold{Eg}:-

var person = {

fullName: function() {

return this.firstName + " " + this.lastName;

}

}

var person1 = {

firstName:"John",

lastName: "Doe"

}

var person2 = {

firstName:"Mary",

lastName: "Doe"

}

person.fullName.call(person1); // Will return "John Doe"

___________________________________

HOPE IT HELPS YOU❤

Similar questions