NG.II · Angular 22 practice question
A developer is using a `signal` to hold an array of user objects. They want the signal to only update its consumers if the actual contents of the array have changed, even if a new array instance is provided. Which configuration should they apply when initializing the signal?
const userList = signal([], { equal: deepObjectComparer });
Check answer and explanation
Correct answer: Provide a custom equality function, such as one implementing deep comparison.
Explanation
Defining a custom equality function empowers the developer to specify the exact criteria for equality, which is necessary when performing deep comparisons on intricate data structures such as arrays.
Common trap
Assuming that signals inherently conduct deep checks for complex data types is flawed, as signals default to checking for reference equality. Furthermore, attempting to utilize the 'byValue' parameter during signal instantiation is incorrect because that API parameter does not exist.
Source: Angular docs: guide/signals/overview — Signal equality functions
Checked against the cited text on 2026-11-25.