I need to use variable arguments to inner function.
I have this function that I cannot change:
function SUM() {
var res = 0;
for (var i = 0; i < arguments.length; i++) {
res += (arguments[i]==null?0:arguments[i]);
}
return mSum(res);
}
Well because this function sometimes returns extra decimal values, I want to wrap it into a function like
function MySUM( return parseFloat(SUM().toFixed(10)) );
the problem is that SUM function cannot read "arguments" of outer function that calls it, and I don't know how to pass this arguments from mySUM to inner SUM function. What I expect is some like this
function MySUM( return parseFloat(SUM(arguments).toFixed(10)) );
but it doesn't work.
SUM()function supposed to return?mSum()? You shouldn't need to check fornullsince js will treat it like 0 in this case.res += arguments[i];should give you the same result forres.