問題文
A method must be passed as a callback and must keep its receiver. Which approach achieves that without changing the call site of the callback?
選択肢
- Wrap the method in another ordinary function before passing it.
- Create a bound version of the method with bind and pass that.
- Declare the method with the arrow syntax in the class body, because a method written that way lands on the prototype and receives the instance as its this when it is later detached.
- Pass the method with call, because call attaches the receiver to the function and returns a version that keeps it, which is the difference between call and apply for this purpose.