liveBook · Manning

Custom comparison method

A custom comparison method is programmer-defined logic that determines how values are compared according to relevant criteria rather than default identity or equality rules.

How 2 Manning books explain it

Build a Frontend Web Framework (From Scratch)

A custom comparison function is a function that determines equality according to criteria defined for the compared values rather than relying on reference identity.

How it is used
Guides array reconciliation when values require domain-specific equality instead of JavaScript reference identity.
How deep it goes
Explains the comparison hook’s role across diff operations but defers the virtual-node equality implementation.
Examples
Uses two structurally identical objects and an array-diff function whose equalsFn defaults to ===.
What you can do after
Apply it via a comparator parameter to make array-diff operations recognize domain-level equality.

Read how Build a Frontend Web Framework (From Scratch) explains custom comparison method →

100 Go Mistakes and How to Avoid Them

A custom comparison method is programmer-defined comparison logic that checks the relevant fields or elements of values.

How it is used
Deploys programmer-defined equality when general deep comparison is too costly at runtime.
How deep it goes
Defines field checks, length checks, early returns, and element iteration, while omitting comparison-library internals.
Examples
Uses customer structs containing an id and operations slice, comparing matching fields and elements.
What you can do after
Build it from scratch by implementing field-specific equality with early exits and collection-element checks.

Read how 100 Go Mistakes and How to Avoid Them explains custom comparison method →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.