While starting at my new job, I have heard constantly the question for the difference between Function.apply
and Function.call
.
Fundamentally, they are equal. Nothing is different in what happens to the function itself. The difference is, though, about how the function will be called.
Function.prototype.apply
expects and array of arguments, while Function.prototype.call
expects a list/component for the arguments.
function test(a, b, c) {
console.log(this); // scope
console.log(Array.prototype.slice.call(arguments));