r/javascript • • Aug 21 '18

Effectively supported in all browsers, JavaScript has its own form of media queries just like CSS.

https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
465 Upvotes

114 comments sorted by

View all comments

-2

u/jutsu9 Aug 22 '18

How is it different from window.innerWidth?

https://developer.mozilla.org/fr/docs/Web/API/Window/innerWidth

6

u/Treolioe Aug 22 '18

Well you can compare their docs and see for yourself

-6

u/jutsu9 Aug 22 '18

Your response is of no value. I have seen the difference of implementation. They can both accomplish the same thing and I want to know if you can do something different with those JavaScript media queries. Only fools don't ask questions. But bigger fools sometime respond.

6

u/Treolioe Aug 22 '18

As the spec reveals you can dynamically react to media queries similar to what you can do in css. These two props literally have nothing in common. You might be able to solve the same problem with either however