W3cubDocs

/Web APIs

DOMMatrixReadOnly: DOMMatrixReadOnly() constructor

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 in Web Workers.

The DOMMatrixReadOnly constructor creates a new DOMMatrixReadOnly object which represents 4x4 matrices, suitable for 2D and 3D operations.

Syntax

DOMMatrixReadOnly()
DOMMatrixReadOnly(init)

Parameters

init Optional

Either a string containing a sequence of numbers or an array of numbers specifying the matrix you want to create.

In case an array of numbers is passed, the behavior depends on the length of the array:

  • for a 6-element array of components in the form [a, b, c, d, e, f], a 2D read-only matrix is created, initialized with the provided components.
  • for a 16-element array of components (in the column-major order) in the form [m11, m12, m13, …, m42, m43, m44], a 3D read-only matrix is created, initialized with the provided components.

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
DOMMatrixReadOnly 61 79 62 48 11 61 62 45 11 8.0 61 11

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrixReadOnly/DOMMatrixReadOnly