JS core · Concept
call vs apply vs bind
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
Difference between call, apply and bind? Give a real use case for each.
Then
Follow-ups the interviewer asks next
- Write
bindfrom scratch (see Polyfills). fn.bind(a).bind(b)(): what isthis? (stilla.)- Partial application with
bind. - Can you
bindan arrow function?
The answer
What a strong answer covers
call(this, ...args)andapply(this, argsArray)invoke immediately;bindreturns a new function withthisand leading args fixed- Uses: borrowing methods (
Array.prototype.slice.call(arguments)),Math.max.apply(null, arr)(now spread), binding handlers - Bound functions ignore later
call/bindthis, butnewstill works on them
The red pen
Common traps
Avoid:thinking bind invokes the function; thinking re-binding works.
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.