解題思路:
(1)首先將類數組轉爲數組,再使用reduce方法,累計求和
function useArguments() {
var result = Array.prototype.reduce.call(arguments,function(a,b){
return a+b;
}); // 轉換爲數組
return result;
}
解題思路:
(1)首先將類數組轉爲數組,再使用reduce方法,累計求和
function useArguments() {
var result = Array.prototype.reduce.call(arguments,function(a,b){
return a+b;
}); // 轉換爲數組
return result;
}