【发布时间】:2017-12-04 06:41:28
【问题描述】:
我是 javascript 新手,当我尝试使用以下代码测试示例时, 代码:
function sayHello(name, age) {
document.write (name + " is " + age + " years old.");
}
<p>Click the following button to call the function</p>
<form>
<input type="button" onclick="sayHello('abc', 010)" value="Say Hello">
</form>
<p>Use different parameters inside the function and then try...</p>
我将参数发送为“abc”和 010。但在输出中我得到如下所示,
输出: abc 8 岁了
【问题讨论】:
-
您应该将
010作为字符串传递。或在连接之前将年龄转换为字符串
标签: javascript parameter-passing