+ 4

[SOLVED] Javascript eval("1"+"2*2") == 24 ????

Given var a = "1" var b = "2*2" console.log(eval(a+b)) I don't understand why the result is 24 and not 14 😲

16th Apr 2021, 12:17 PM
David OrdĂĄs
David OrdĂĄs - avatar
2 Answers
+ 10
+ concat 2 strings, so "1" + "2*2" "12*2"
16th Apr 2021, 12:20 PM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
Thanks CarrieForle first concatenate and then eval
17th Apr 2021, 12:51 AM
David OrdĂĄs
David OrdĂĄs - avatar