找出数字数组中最大的元素(使用Math.max函数)var arr = [61, 22, 31, 4, 5]; // 方法1 var max = 0; arr.forEach(function (value, index) { max = Math.max(value, max); }); // 方法2 Math.max.apply(null, arr)转化一个数字数组为function数组(每个function都弹出相应的数字)var arr = [61, 22, 31, 4, 5]; var arr2 = arr.map(function (value, index) { return function () { alert(value); }; });给object数组进行排序(排序条件是每个元素对象的属性个数)var arr = [ {a:1, c:2, d:3, f:5, e:2}, {a:1}, {a:1, b:2, c: 3}, {a:1, b:2} ]; function objectSort(a, b) { var num1 = 0, num2 = 0; for (var i in a) { num1 += 1; } for (var j in b) { num2 += 1; } return n
...
继续阅读
(39)