When to execute javascript functions

I want to execute a javascript function but only at a specific media query

@media (min-width: 992px) {

}

CSS can’t determine directly if JS can execute or not, you need to write the check in your JS code