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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -