How JavaScript gets the maximum and minimum values in the array:
Compared to the size of the values in the array of common operations, compared to the size of a variety of methods, such as the use of the self-contained sort () function, the following to introduce the other more commonly used methods, the code is as follows:
functionGetmaximin (arr,maximin) {if(maximin== "Max") { returnMath.max.apply (Math,arr); } Else if(maximin== "Min") { returnMath.min.apply (Math, arr); } } vara=[3,2,4,2,10]; varb=[12,4,45,786,9,78]; Console.log (Getmaximin (A,"Max"));//TenConsole.log (Getmaximin (b, "Min"));//Geneva
The above code can be implemented to remove the maximum and minimum values from the array.
Related reading:
The 1.math.max () function can be found in the Math.max () method section of JavaScript .
The 2.math.min () function can be foundin the section of the Math.min () method of Javascript.
The 3.apply () function can refer to the function and Difference section of the JavaScript call () and apply () .
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=8819
For more information, refer to: http://www.softwhy.com/javascript/
How JavaScript gets the maximum and minimum values in an array