bhylu.com

Advertisements

Temporal Mistakes

Use the correct Temporal type and handle unsupported runtimes. PlainDate month numbers start at one, unlike Date month indexes.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

if (typeof Temporal === "undefined") {
  console.log("Temporal is not available in this runtime. Use a supporting browser or a reviewed local polyfill.");
} else {
  const date = Temporal.PlainDate.from({year: 2026, month: 11, day: 7});
  console.log(date.month);
}

What happens

The month is 11.