Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

The JavaScript call() Method


		const person = {
name: "John Smith",
getNameAndAddress: function(city, country)
{
return this.name+city+country;
}

}
const personWithoutGet = {
name: "Jerry Smithers"}

 console.log(person.getNameAndAddress.call(personWithoutGet, 'Berlin','Germany'));
/*you can think of bind(), apply() and call() ALL as "stealing someone else's function to use."*/
/* victimBeingStolenFrom.functionName.call(theThief) */
/*notice the second variable personWithoutGet does not have a getName function*/
Source by workat.tech #
 
PREVIOUS NEXT
Tagged: #The #JavaScript #Method
ADD COMMENT
Topic
Name
9+4 =