方法一:
function sortNumber(a,b){ return a - b } function min() { var arr = [] for (var i=0; i<arguments.length; i++){ arr[i] = arguments[i] } document.write(arr.sort(sortNumber)[0]) } min(2, 4, 1, -1, 56, 3, -7)
方法二:
function min() { var minNumber=arguments[0]; for (var i=1; i<arguments.length; i++){ if (minNumber >= arguments[i]){ minNumber = arguments[i] } } document.write(minNumber) } min.apply(window,[2, 4, 1, -1, 56, 3, -7])