Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
Operator to test for falsy values with zero treated as truthy

Is there a minimalistic syntax to do the same as x === 0 ? true : !!x. The goal of this expression is to avoid the exclusion of zero as falsy and yet make sure other falsy values do are converted to false.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Basically, you want to allow any number?

typeof x === 'number'
about 4 years ago · Juan Pablo Isaza Report

0

The most minimalist syntax I can think of is

x === 0 || Boolean(x)
about 4 years ago · Juan Pablo Isaza Report

0

I'm not sure that there's a better solution than what you've got. You could also use !!x || x === 0 though

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!