Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 139953

Check if falsy except zero in JavaScript

$
0
0

I am checking if a value is not falsy with

if (value) {
  ..
}

but I do want to accept zeros as a (non-falsy) value. How is this normally done? Would it be

if (value || value === 0) {
  ..
}

or what?


Viewing all articles
Browse latest Browse all 139953

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>