[javascript]取数组中最大的数值
//var arr = new Array(1,12,4,124.45,8,99998,456);
var arr = [1,12,4,124.45,8,99998,456];
var a = Math.max.apply(Math,arr);
var b = Math.max.apply({},arr);
var c = Math.max.apply(null,arr);
var d = Math.max.apply('',arr);
var e;
(function(){
for(var k=0;k<(arr.length-1);k++){
if(arr[k]>arr[k+1]){
e=arr[k];
}else{
e=arr[k+1];
}
}
})();
console.log(a);
console.log(b);
console.log(c);
console.log(d);
console.log(e);