Use Array.apply() to find Max and Min value from an Array

   JavaScript

Array.apply() applies to all of an array’s items. It applies the given function to each item in an array, one by one, storing each result in place of the value that was used to generate it.

const nums = [2, 54, 8, -5, 9];

const max = Math.max.apply(null, nums);
// prints-> 54

const min = Math.min.apply(null, nums);
// prints-> -5

Tags: Array.apply()JavaScriptMaxMin

Leave a Comment