matchMedia is for, but that isn’t as supported as media queries are and requires you to maintain those breakpoints is both CSS and JS.
Mike Herchel’s solution is to change the
Three thoughts: 1) If you’re binding on resize, probably debounce. 2) If you can’t or don’t want to debounce, at test if the value has actually changed before performing any more work. 3) Have a good naming strategy for the breakpoints.