Get maximum and minimum value from an array values in JS

Last updated on 12/05/2014
var arrayVals = [1,2,4,3];
var maxVal = Math.max.apply(Math,arrayVals); // 4
var minVal = Math.min.apply(Math,arrayVals); // 1