正解:B,D
The correct constructor signature for CustomEvent is:
new CustomEvent(eventName, optionsObject)
Where:
* eventName is a string.
* optionsObject may include:
* detail # used to pass custom data
* bubbles
* cancelable, etc.
Example:
new CustomEvent( ' update ' , {
detail: { recordId: ' 123abc ' }
});
Now evaluate each option:
Option A
{ type: ' update ' , recordId: ' 123abc ' }
Incorrect: The constructor requires (eventName, options), not a single object. type is not used this way.
Option B
' update ' , { detail: { recordId: ' 123abc ' } }
Correct format. detail is the proper place for custom event data.
Option C
' update ' , ' 123abc '
Incorrect: The second argument must be an object (options), not a string.
Option D
' update ' , { recordId: ' 123abc ' }
Acceptable because any extra properties on the options object are still allowed, even though best practice is to use detail.
This still creates a valid CustomEvent, and the event will dispatch successfully.
Thus the two correct answers are B and D .
JavaScript Knowledge References (text-only)
* new CustomEvent(name, options) is the required syntax.
* The detail property of the options object is the standard location for custom data.
* The second argument must be an object; other types are invalid.