Which Is Better To Use For A Calculator Parseint() Or Eval() In Javascript?
The numbers are in a input text field so when i retrieve it it is in a string. Which I can get the answer but would it be better to use parseInt.
Solution 1:
In general, avoid using eval
, especially with user input. Arbitrary code execution is almost never what you wanted to do in the first place. As long as the use can't enter a decimal number, parseInt
is the way to go.
Post a Comment for "Which Is Better To Use For A Calculator Parseint() Or Eval() In Javascript?"