フリー問題

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

問題文

An async function awaits a call that rejects. The surrounding code needs to handle the failure. Which construct handles it?

選択肢

  1. A try block around the await, with the failure handled in the matching catch block.
  2. A window level error listener, which is the intended place for handling rejections of any kind.
  3. An outer try block placed around the call that starts the async function without awaiting it, because the rejection travels up the call stack of the caller in the same way an ordinary exception does.
  4. An if statement that compares the awaited result of the call against undefined, because a rejected call evaluates to undefined instead of throwing an error object.

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

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