关于定义变量的问题,然后赋值求和,出现了问题,求解释?
check
check 2016-12-21 09:40:39
0
2
933
var mynum,mymun,sum;
mynum="8"; mymun="7"; 
sum=mynum+mymun;
document.write(sum);

为啥输出的结果是87,不是15


check
check

reply all(2)
数据分析师

About the problem of defining variables, then assigning values ​​and summing, a problem occurs, please explain? -PHP Chinese website Q&A-About the problem of defining variables, then assigning values ​​and summing, a problem occurs, please explain? -PHP Chinese website Q&A

Please watch and learn.

迷茫

问题出在你定义mynum="8"; mymun="7"; 

也就是说你将mynum定义为字符“8”,而非数字8,这两者是有完全不同的。mynun同理。

解决方法:mynum = 8 ; mymun = 7 ;


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template