The apply() Method
apply() and call() are actually pretty similar. Both methods explicitly define the value of this, but they have different ways of taking arguments. For both methods, the first parameter will be the object that we want to be the value of this. However, instead of accepting an endless number of arguments, the second parameter of apply() will be an array containing all the arguments we wish to pass to the function:
Copy code
JAVASCRIPT
const car = {
  registrationNumber: 'O287AE',
  brand: 'Tesla'
};

function displayDetails(greeting, ownerName) {
  console.log(`${greeting} ${ownerName}`);
  console.log(`Car info: ${this.registrationNumber} ${this.brand}`);
}

displayDetails.apply(car, ['Hello', 'Matt']);

/*

  Hello Matt
  Car info: O287AE Tesla

*/