reference equality

Comparing two references to see whether they point to the very same object, rather than to objects with equal contents.

In more detail

Two separately created objects with identical contents are equal by value but not by reference. Many languages compare objects by reference by default, and libraries such as React use reference equality to decide whether something changed, so a new object with the same contents counts as a change.

Examples

C#: object.ReferenceEquals(a, b)
Java: == compares references for objects; use equals for content, as in "a".equals(text).
React relies on reference equality for state, props, context values and dependency arrays; useMemo, useCallback and state setters help keep references stable.

Related terms

Taught in

References

Certification courses