Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

133
Vistas
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 Respuestas
Responde la pregunta

0

Basically, you want to allow any number?

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

0

The most minimalist syntax I can think of is

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

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda