Well... below code returns the first occurance of value in the array.
indexvalue = yAxisdata.indexOf(maxvalue);
To get second occurance of value, use this:
secondindex = yAxisdata.indexOf(maxvalue, yAxisdata.indexOf(maxvalue)+1);
To get more examples, visit this thread:
javascript - How to get the position of the second occurrence? - Stack Overflow[
^]