find min and max number in array javascript code example

Example 1: javascript min max array

Math.max(1, 2, 3)    // 3
Math.min(1, 2, 3)    // 1

var nums = [1, 2, 3]
Math.min(...nums)    // 1
Math.max(...nums)    // 3

Example 2: find min and max date in array javascript

const dates = [];
dates.push(new Date('2011/06/25'));
dates.push(new Date('2011/06/26'));
dates.push(new Date('2011/06/27'));
dates.push(new Date('2011/06/28'));
const maxDate = new Date(Math.max.apply(null, dates));
const minDate = new Date(Math.min.apply(null, dates));