JavaScript apply() Explained Simply
The only difference between apply() and call() is that the second parameter of the apply() method accepts the arguments to the actual function as an array.
function describe(item, quantity) {
return `${this.name} ordered ${quantity} ${item}`;
}
const customer = { name: "Sam" };
const order = ["notebooks", 3];
console.log(describe.apply(customer, order)); AI panel
Ask AI to clarify the parts you don’t fully understand, or go more in depth with MDN documentation.