计算数组最大值

d3.max = function(array, f) {
var i = -1, n = array.length, a, b;
if (arguments.length === 1) {

//取数组中第一个非undefined数值
while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined;
while (++i < n) if ((b = array[i]) != null && b > a) a = b;
} else {
while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined;
while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
}
return a;
};

  

原文地址:https://www.cnblogs.com/yoyogis/p/3862966.html