How to find max value in a JavaScript Array

How to find biggest value in a JavaScript array


Finding biggest value in a array involves comparing each values, that’s not much fun. But JS let us save some code, it provide easy Math function for the purpose.

Using the Math.max

  max: Math.max.apply(null,this.myarray

The above function will compare each value and find the biggest value in myarray list. Is this useful ?

I found this useful when I work with charts, finding biggest will allow me to set axis value dynamically.

Following posts also deserve a good read

Author: Manoj

Developer and a self-learner, love to work with Reactjs, Angular, Node, Python and C#.Net

One thought on “How to find max value in a JavaScript Array”

Leave a comment

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