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

169
Views
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 answers
Answer question

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 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!