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

167
Vistas
Javascript, log what causes a boolean expression to fail

I have a complex predicate in JavaScript that chains various tests against a value.

I'd love to log where in the expression it fails, if it fails. Sort of like testing libraries that log out where an exception fails.

Is there some sort of reflection I can do to extract some pretty description of what caused an expression to fail?

e.g.,

const predicate = a.foo == 1 && a.bar < 3 && someOtherPredicate(a.bar)

// if predicate == false, console.log ->
// "error: b.bar < 3 evaluated to false"

(I'm actually interested in doing this in Typescript, but want to see what features JavaScript has that could enable this)
about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

why don't you try debugging to check where this expression actually failing. put debugger; before your expression open up the console tab and keep observing your output w.r.t. your input

about 4 years ago · Santiago Gelvez 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