Your preferred style(s) for checking for nullish in JavaScript:

@wallhackio Why would you ever write any of the above two options instead of if (!x)? Asking as a C programmer. Are there any situations where these do different things?

@vaporeon_ there are non-nullish values that are coerced to false. or x could be false itself. That means the following values would also be treated as nullish:

false
""
0
-0
0n
NaN

@wallhackio @vaporeon_ this is a better answer than mine

0n is an arbitray purrecision integer literal ftr

re: no image descriptions 

@aescling @wallhackio Can you explain to Vaporeon what is happening here?

Follow

re: no image descriptions 

@vaporeon_ @wallhackio i am showing that, in the browser, document.all exists and is an object. boolean conversion of document.all purroduces false, which the exception to the rule that objects are always truthy (which is to say, the rule that the interal boolean coercion mechanism always purroduces true when coercing an object)

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.