這裏爲(wèi)什麼會出現(xiàn)UNDEFINED
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函數(shù)傳參</title>
<script type="text/JavaScript">
?? function? add3(x,y,z)????????????? ?
?? ?{
?? ?? sum = x + y +z;
?? ?? document.write(x+"、"+y+"、"+z+"和:"+sum+"<br/>");
?? ?}
?? ? document.write(add3(5,8,3));
?? ? document.write(add3(7,1,4));
?? ? document.write(add3("sss",123,"725672385098365"))
?? ?
</script>
</head>
<body>
</body>
</html>
5、8、3和:16
undefined7、1、4和:12
undefinedsss、123、725672385098365和:sss123725672385098365
undefined
2017-03-24
第一個document.write(x+"、"+y+"、"+z+"和:"+sum+"<br/>");中的x+"、"+y+"、"+z+"和:"+sum+"<br/>"沒有定義過,所以輸出undefined,? x,y,z是方法需要的參數(shù),但不是實(shí)際聲明過的參數(shù),是調(diào)用函數(shù)時需要傳進(jìn)去的,