参数不用声明了??
function add2(x,y)
{
sum = x + y;
document.write(sum);
}
function add2(x,y)
{
sum = x + y;
document.write(sum);
}
2017-05-24
function add3(var x,var y,var z)
{
sum = x + y +z;
document.write(x+"、"+y+"、"+z+"和:"+sum+"<br/>");
}
既然可以声明,为什么这样子却运行不了呢。完整代码如下:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函数传参</title>
<script type="text/JavaScript">
function add3(var x,var y,var z)
{
sum = x + y +z;
document.write(x+"、"+y+"、"+z+"和:"+sum+"<br/>");
}
add3(5,8,3);
add3(7,1,4);
</script>
</head>
<body>
</body>
</html>
举报