<pre name="code" class="javascript"><!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
/**
*检测JS中字符串和数字相加的结果是什么
*经测试,结果是字符串
*/
var str = 'Hello';
var res = str + 2;
alert(res);
</script>
</body>
</html>
结果是Hello2
<pre name="code" class="javascript"><!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
/**
*检测JS中字符串和数字相加的结果是什么
*经测试,结果是字符串
*/
var str = 'Hello';
var res = str + 2;
alert(res);
</script>
</body>
</html>