NotRestoredReasons: toJSON() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

We’d love to hear your thoughts on the next set of proposals for the JavaScript language. You can find a description of the proposals here.
Please take two minutes to fill out our short survey.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The toJSON() method of the NotRestoredReasons interface is a serializer; it returns a JSON representation of the NotRestoredReasons object.

Syntax

js
toJSON()

Parameters

None.

Return value

A JSON object that is the serialization of the NotRestoredReasons object.

Examples

The following function will return a JSON representation of the NotRestoredReasons object of the first PerformanceNavigationTiming object currently present in the performance timeline:

js
function returnNRR() {
  const navEntries = performance.getEntriesByType("navigation");
  let navEntry = navEntries[0];
  return navEntry.notRestoredReasons.toJSON();
}

Specifications

Specification
HTML
# notrestoredreasons

Browser compatibility

See also