CKTIS / JavaScript
MediaQueryList.matches — media query match state
MediaQueryList.matches is a read-only boolean property indicating whether a media query matches the document's current state.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
const mql = window.matchMedia(query);
const matches = mql.matches;MediaQueryList.matches returns true when its associated media query list matches the document's state, and false otherwise. Obtain the object with window.matchMedia(query). This is a read-only property, not a method: use mql.matches, not mql.matches().
The object's value can change. A previously saved boolean does not update automatically. To react to matching changes, listen for change; reading the property alone does not register a listener.
The example uses all and not all, so its output does not depend on window size. This is a CSSOM View browser Web API, not an ECMAScript feature; Node 24 does not establish its availability.
Examples
const queries = ["all", "not all"];
for (const query of queries) {
const mql = window.matchMedia(query);
console.log(`${query}: ${mql.matches}`);
}Result
all: true not all: false
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.