0

I'm using the JavaScript engine in JDK 7. Is there a way to evaluate an expression like a||b to false if a and b are undefined, instead of throwing the exception ReferenceError: "a" is not defined.?

Adrian Ber
  • 20,474
  • 12
  • 67
  • 117

1 Answers1

0

I don't think this is possible.

I took the following approach to achieve what I wanted. I was evaluating the expression and if that expression was failing, I was adding the undefined variable to the context and try to reevaluate again.

Adrian Ber
  • 20,474
  • 12
  • 67
  • 117