JavaScript variables can be declared and used in MDX files.Declare Variables.Variables used throughout the page are declared in the MDX file using export.
Copy
export const openTime = new Date();
Referencing Variables.Declared variables are referenced by enclosing them in {}.
Copy
export const openTime = new Date();The time the page was opened is { openTime.toLocaleString() }
The result is as follows.The time the page was opened is
The content enclosed in {} is evaluated as a JSX node and must be either a string, boolean, number, null, undefined, or React component.
Assistant
Responses are generated using AI and may contain mistakes.