The window.matchMedia() method checks whether a media query applies to the document.
window.matchMedia()