I have an object containing arrays of objects. I’m trying to find the highest value of an object property, ‘sortOrder’ without manually iterating through the arrays and objects. So my variable looks like this following: So I’d be trying to iterate through this to eventually find, in this case, the highest sortOrder of 33. Not necessarily the array index or
Tag: max
Javascript Select vector with the greatest number of items [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I have 4 arrays: Note: Length of array length is different in any session I need to select array with greatest number of items, (Class_B)
Return index of greatest value in an array
I have this: What’s the best way to return the index of the highest value into another variable? Answer This is probably the best way, since it’s reliable and works on old browsers: There’s also this one-liner: It performs twice as many comparisons as necessary and will throw a RangeError on large arrays, though. I’d stick to the function.
How might I find the largest number contained in a JavaScript array?
I have a simple JavaScript Array object containing a few numbers. Is there a function that would find the largest number in this array? Answer Resig to the rescue: Warning: since the maximum number of arguments is as low as 65535 on some VMs, use a for loop if you’re not certain the array is that small.