You can use .reduce()
…
array.reduce(function(max, arr) {
return Math.max(max, arr[0]);
}, -Infinity)
Here’s a version that doesn’t use Math.max
…
array.reduce(function(max, arr) {
return max >= arr[0] ? max : arr[0];
}, -Infinity);
…and a jsPerf test.
More Related Contents:
- Sorting array of object based on range of Numbers of String [closed]
- How to find the sum of an array of numbers
- JQuery .each() backwards
- Why does typeof array with objects return “object” and not “array”? [duplicate]
- How to add an object to an array
- Parsing JSON objects for HTML table
- Check if an array is empty or exists
- Filter array of objects with another array of objects
- Find and remove objects in an array based on a key value in JavaScript
- How to count the number of occurrences of each item in an array? [duplicate]
- Using jQuery to compare two arrays of Javascript objects
- Get unique results from JSON array using jQuery
- Compare 2 arrays which returns difference
- How to Compare two Arrays are Equal using Javascript? [duplicate]
- What is the most efficient way to sort an Html Select’s Options by value, while preserving the currently selected item?
- Javascript algorithm to find elements in array that are not in another array
- Filter strings in Array based on content (filter search value)
- What does $(selector)[0] mean in jQuery?
- jQuery min/max property from array of elements
- remove item from array using its name / value
- can phantomjs work with node.js?
- How to loop through array in jQuery?
- Remove occurrences of duplicate words in a string
- Can I append an array to ‘formdata’ in javascript?
- Create array of all integers between two numbers, inclusive, in Javascript/jQuery
- Convert js Array() to JSon object for use with JQuery .ajax
- How to find a value in an array of objects in JavaScript?
- Sorting an Array of JavaScript Objects a Specific Order (using existing function)
- Find object having maximum value for the `id` property in an array of objects
- Getting max value(s) in JSON array