A developer is troubleshooting a Lightning Web Component where data returned from an Apex wire adapter needs to be mutated before being rendered. What is the correct pattern to handle this?
Wire adapter data is read-only and frozen, so direct mutation throws in strict mode. Cloning via spread or structuredClone in a getter or property assignment produces a mutable copy, satisfying the stem's need to transform Apex-returned data before rendering without breaking reactivity.
Why this answer
Data returned from an Apex wire adapter is immutable (read-only). To mutate it, you must create a shallow copy or clone of the object before making changes. This can be done in a getter or by assigning the copied data to a new property.
This pattern ensures you do not attempt to modify the original wire data, which would cause an error.
Exam trap
The trap is assuming that wire data can be directly mutated, or that decorators like @api can make it mutable; candidates may overlook the immutability constraint.
How to eliminate wrong answers
Option A is wrong because @api mutable is not a valid decorator; @api is used to expose public properties, but it does not make wire data mutable. Option B is wrong because using eval() to strip immutability is a hack and not recommended; it can lead to security issues and is not a supported pattern. Option D is wrong because directly assigning new properties to the wire data object will fail silently or throw an error in strict mode, as the object is frozen.