HTML文件,建议用Visual Studio Code或者HBuilder X打开查看
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>arguments</title>
<script>
//arguments是当前函数的内置对象(只有函数有),储存了所有实参,通常用于不确定实参个数实传递参数
//arguments的使用
function fu() {
console.log(arguments);
console.log(arguments[0]);
}
fu(1, 2, 3); //arguments以伪数组形式储存所有实参,可以遍历。
//有length长度属性
//没有push、pop的方法。
console.log('');
function getmax() {
var max = 0;
for (var i = 0; i < arguments.length; i++)
if (arguments[i] > max)
max = arguments[i];
return max;
}
console.log(getmax(1, 5, 61, 24, 5, 8, 44, -18, 0));
console.log(getmax(1, 5, 61, 24, 5, 8, 44, -18, 110,25,5552));
</script>
</head>
<body>
</body>
</html>