Find max value in Array JavaScript | Example code

The built-in functions Math.min() find the maximum value of the given Array in JavaScript. But These functions will not work as-is with arrays of numbers.

Function.prototype.apply() allows you to call a function with a given this value and an array of arguments.

Find max value in Array JavaScript Example code

HTML complete code:-

Passing the numbers array as the second argument of apply() results in the function being called with all values in the array as parameters.

Output:

Find max value in Array JavaScript

Using spread operator

Do comment if you have any doubts and suggestions on this JS Array topic.

Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.