Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 jquery,如何获得数组或数字中的最大值?
例子:
var myArray = [1,4,7,3,12,0]
预期输出:-
最大值 = 12
如果按最高数字表示最大值,则不需要 jQuery。你可以这样做:
var myArray = [9,4,2,93,6,2,4,61,1]; var maxValueInArray = Math.max.apply(Math, myArray);