Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The Temporal.PlainYearMonth.compare()
static method returns a number (-1, 0, or 1) indicating whether the first year-month comes before, is the same as, or comes after the second year-month. It is equivalent to comparing their underlying ISO 8601 dates. Two year-months from different calendars may be considered equal if they start on the same ISO date.
Note: PlainYearMonth
objects keep track of a reference ISO day, which is also used in the comparison. This day is automatically set when using the Temporal.PlainYearMonth.from()
method, but can be set manually using the Temporal.PlainYearMonth()
constructor, causing two equivalent year-months to be considered different if they have different reference days. For this reason, you should avoid using the constructor directly and prefer the from()
method.