javascript - Weird eval output -
try below code snippet, giving weird results. explain it?
var s = "10+10"; alert("evaluation 1: " + eval(s+s+s)); // 2040 alert("evaluation 2: " + eval(s+2)); // 112
output expecting 30 , 22
nothing weird @ all:
s + s + s === "10+10" + "10+10" + "10+10" === "10+1010+1010+10" => 2040 s + 2 === "10+10" + "2" === "10+102" => 112
Comments
Post a Comment