var mynum,mymun,sum; mynum="8"; mymun="7"; sum=mynum+mymun; document.write(sum);
为啥输出的结果是87,不是15
数据分析师2017-09-30 23:19:14
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.
迷茫2016-12-21 09:41:44
问题出在你定义mynum="8"; mymun="7";
也就是说你将mynum定义为字符“8”,而非数字8,这两者是有完全不同的。mynun同理。
解决方法:mynum = 8 ; mymun = 7 ;