valueOf
Returns the canonical month string (YYYY-MM). It defines how a Month coerces
to a primitive, so template strings and string concatenation stay at month
precision.
API Reference
Signature
Parameters
None.
Returns
Returns the canonical YYYY-MM string, regardless of any day anchor.
Agent Contract
Agent Notes
valueOfalways stays at month precision; usetoString({ precision })for explicit year or day output.valueOfreturns a string, not a number. Relational operators (monthA < monthB) work because the fixed-widthYYYY-MMform orders lexicographically, but numeric coercion (+month,monthA - monthB) yieldsNaNby design. Use diff for signed month differences.- Comparison between
Monthvalues should use the comparison methods, not relational operators on the coerced string.