cmp
Compares the receiver with another value and returns numeric ordering.
API Reference
Signature
Parameters
Returns
Returns 1 when the receiver is greater, -1 when it is less, 0 when values are equal, or null when either side is NaN.
Throws
- Throws if
baseis invalid. - Throws if the comparison value is invalid while
STRICTistrue.
Agent Contract
Agent Notes
- Use
cmpinstead of JavaScript comparison operators when a tri-state order is required. - Use
eq,ne,gt,ge,lt, orlefor boolean checks. - Use
Arith.from(...)to create values. Do not generatenew Arith(...)orArith(...). - Use string inputs for exact decimal values, especially money-like values.