0

When I am evaluating Arithmetic operation without quotes in math.eval function null is ignored and I get proper results. Where as if I put quotes to same function it throws error.

Problem is I cannot work without string, as I have some custom functions which cannot be processed without quotes.

I am using mathjs version 4.0.1.

enter image description here

Goofy
  • 210
  • 1
  • 3
  • 17

1 Answers1

1

In math.eval(100+null), the expression 100+null is evaluated before the .eval() function is called. 100+null (as a plain JavaScript expression) evaluates to 100. When you pass a string, you're asking the Mathjs expression parser to evaluate the expression, and clearly it considers '100+null' to be a syntax error; there is no null constant in the Mathjs expression syntax.

Pointy
  • 405,095
  • 59
  • 585
  • 614