<script>
function maxNum() {
var max = arguments[0];
for (var i = 1; i < arguments.length; i++) {
if (arguments[i] > max) {
max = arguments[i];
}
}
console.log(max);
}
maxNum(3, 1, 5, 66, 7);
maxNum(9, 22, 66, 99);
</script>
输出结果:
<script>
function maxNum() {
var max = arguments[0];
for (var i = 1; i < arguments.length; i++) {
if (arguments[i] > max) {
max = arguments[i];
}
}
console.log(max);
}
maxNum(3, 1, 5, 66, 7);
maxNum(9, 22, 66, 99);
</script>
输出结果: