+ 1
What method to use besides eval() on calculator
I just stumbled upon a Q&A forum and one of the comments their is don't use eval() because it makes the browser slower and other consequences. What should I use instead?
8 Réponses
+ 1
You should implement your own function to evaluate expressions.
+ 1
Using eval, the browser will be slower, but not for all (slower mostly for drawings).
And eval is the best solution for creating a calculator!
+ 1
michal , your answer gives me an idea. Thanks
+ 1
Writing your own function isn't something easy : there are lot of conditions, and it can become as slower as the eval function...
+ 1
Théophile what do you propose to use?
+ 1
Just use eval... No idea. I'm looking for something else in internet. If I find something, I tell you.
+ 1
The problem with eval is that a malicious user might input some bad code and let it evaluate.
+ 1
So, Is there an other function that works like eval?