+ 2
alert(5/8+"hi") & console. log(25*87) evaluate the sum and sends to the console/prompt. Why use alert(eval(5/8+"hi))?
Does Alert() have eval() built in?
5 Answers
+ 2
Not really.
With eval, "5*5" and 5*5 will both be 25
With alert, only 5*5 will be 25, and "5*5", well, stays "5*5"
Eval's point is that it will execute strings, so
eval("alert('x')") will execute, and x will be alerted
+ 2
Am I missing the point of eval then? lol typical
https://code.sololearn.com/WP0UvZRw4o41/?ref=app
+ 1
https://code.sololearn.com/W8PjLKojM7xT/?ref=app
+ 1
eval is for strings like inputs then. Got it. Thanks for the clarification Aimee.
+ 1
Yes, so if you want to, I don't know, make a graph displayer (winkyface) (winkyface), that is extremely useful, so you can get the function very easily, so you can get an input like "18 * x ** 2 + 9 * x + 5 * sin(x)", you can easily use eval