DOMPointReadOnly: toJSON() method
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Note: This feature is available inWeb Workers.
TheDOMPointReadOnly methodtoJSON() returns an object giving theJSON form of the point object.
In this article
Syntax
js
toJSON()Parameters
None.
Return value
A new object whose properties are set to the values in theDOMPoint orDOMPointReadOnly on which the method was called.
Examples
This example creates aDOMPoint object representing the top-left cornerof the current window, in screen coordinates, then converts that to JSON.
js
const topLeft = new DOMPoint(window.screenX, window.screenY);const pointJSON = topLeft.toJSON();Specifications
| Specification |
|---|
| Geometry Interfaces Module Level 1> # dom-dompointreadonly-tojson> |