Is it wrong to use the eval function to compute values in a calculator JavaScript project. If it's wrong, what other can be used | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is it wrong to use the eval function to compute values in a calculator JavaScript project. If it's wrong, what other can be used

11th Jul 2022, 4:42 PM
Kehinde
Kehinde - avatar
2 Answers
+ 2
You can use it, but some said that eval() can be used for hacking, so is not secure to use in code, if you dont know how to prevent it. Al least I read this somewere on internet. You should make your own eval function to compute values. Here is documentation about eval, even thay said to never use eval, maybe this can help you to understand much more about it, and to see some solutions without eval: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
11th Jul 2022, 4:47 PM
PanicS
PanicS - avatar
+ 1
Thanks PanicS
11th Jul 2022, 5:03 PM
Kehinde
Kehinde - avatar