フリー問題

Salesforce Certified JavaScript Developer のフリー問題 7 / 20 問目

問題文

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?

選択肢

  1. Wrap the method in another ordinary function before passing it.
  2. Create a bound version of the method with bind and pass that.
  3. 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.
  4. 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.

解答・解説を確認するには

正解と解説の確認、回答の記録には無料登録が必要です。登録すると演習モードでフリー問題に回答し、正誤と解説をその場で確認できます。