call, apply, and bind Interview Questions
Common interview questions about call, apply, and bind with answers.
call, apply, and bind Interview Questions
Q1: What is the output?
const obj = { x: 10 }; function foo(y) { return this.x + y; } console.log(foo.call(obj, 5));
Answer: 15.
Q2: What is the output?
const obj = { x: 10 }; function foo(y, z) { return this.x + y + z; } console.log(foo.apply(obj, [5, 3]));
Answer: 18.
Q3: What is the output?
const obj = { x: 10 }; function foo(y) { return this.x + y; } const bound = foo.bind(obj, 5); console.log(bound());
Answer: 15.
Q4: Implement a function that borrows slice from Array.
function toArray(arr) { return Array.prototype.slice.call(arr); }
Q5: Can you re-bind a bound function?
No. bound.bind(newObj) does not change this. The first bind wins.
Q6: What happens if you call bind on an arrow function?
Nothing. The arrow's this is lexical and cannot be changed by bind, call, or apply.
The Takeaway
Interview questions: output prediction (call with this + args, apply with array, bind + call later), method borrowing (Array.prototype.slice.call), re-binding (not possible), and arrows (ignore bind). Practice each.
No. The first bind wins. bound.bind(newObj) does not change this. The bound function keeps the original this from the first bind call.
Array.prototype.slice.call(arguments). This borrows the slice method from Array.prototype and applies it to the array-like arguments object.
Nothing. The arrow function's this is lexical (inherited from the enclosing scope). bind, call, and apply cannot change an arrow's this.
15. call sets this to obj (so this.x is 10) and passes 5 as y. 10 + 5 = 15.
18. apply sets this to obj (this.x = 10) and passes [5, 3] as y and z. 10 + 5 + 3 = 18.
Ready to master React completely?
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.
Master React
Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course.

