JavaScript · Middle · Question 2 of 75
How do call, apply and bind differ from each other?
- ✓Correct answer:
call/applyinvoke immediately,bindreturns a new function - 2
bindinvokes the function immediately, whilecallandapplyreturn new functions - 3
applyworks only with arrow functions, the others with regular ones
Explanation
fn.call(ctx, a, b) and fn.apply(ctx, [a, b]) invoke immediately with the given this. fn.bind(ctx, a) returns a function with a permanently bound context and partially applied arguments. None of them affect arrow functions: they have no own this.