フリー問題

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

問題文

A developer writes the following two lines after declaring const settings = { theme: 'dark' }; First: settings.theme = 'light'; Second: settings = { theme: 'light' }; What happens when this code runs?

選択肢

  1. Both lines throw a TypeError, because a variable declared with const is deeply immutable once the declaration has been evaluated.
  2. The first line succeeds and the second line throws a TypeError, because const fixes the binding rather than the contents of the object.
  3. Both lines succeed and settings ends up holding the second object with the theme value set to light.
  4. The first line throws a TypeError and the second line succeeds, because a whole new object replaces the binding cleanly.

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

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