Explanation of code for checking CSS.supports () before using it

I saw this piece of code recommended for testing CSS.supports() support before using it:

 var supportsCSS = !!((window.CSS && window.CSS.supports) || window.supportsCSS || false); 

I understand everything except the need for the || false || false Can someone explain this?

EDIT:

Sources:

https://davidwalsh.name/css-supports

https://medium.com/@barvysta/css-support-directive-and-its-js-twin-ready-to-use-6eea2fefef36

And these are not the only ones. This is pretty common.

+5
source share
1 answer
 var supportsCSS = !!((window.CSS && window.CSS.supports) || window.supportsCSS || false); 

I think that false does not mean zero, but else.

window.CSS.supports is the current syntax, and window.supportsCSS is the old syntax.

I mean that false can be replaced with window.CSS.require_supports in the future.

!! used to emphasize the code that I think.

0
source

Source: https://habr.com/ru/post/1269365/


All Articles