[javascript] Obtain smallest value from array in Javascript?

For anyone out there who needs this I just have a feeling. (Get the smallest number with multi values in the array) Thanks to Akexis answer.

if you have let's say an array of Distance and ID and ETA in minutes So you do push maybe in for loop or something

Distances.push([1.3, 1, 2]); // Array inside an array.

And then when It finishes, do a sort

Distances.sort();

So this will sort upon the first thing which is Distance here. Now we have the closest or the least is the first you can do

Distances[0] // The closest distance or the smallest number of distance. (array).

Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to arrays

PHP array value passes to next row Use NSInteger as array index How do I show a message in the foreach loop? Objects are not valid as a React child. If you meant to render a collection of children, use an array instead Iterating over arrays in Python 3 Best way to "push" into C# array Sort Array of object by object field in Angular 6 Checking for duplicate strings in JavaScript array what does numpy ndarray shape do? How to round a numpy array?

Examples related to min

Min and max value of input in angular4 application Python find min max and average of a list (array) How do I get the max and min values from a set of numbers entered? SQL: Group by minimum value in one field while selecting distinct rows How to exclude 0 from MIN formula Excel Using std::max_element on a vector<double> How can I get the max (or min) value in a vector? Most efficient way to find smallest of 3 numbers Java? Find the smallest amongst 3 numbers in C++ Obtain smallest value from array in Javascript?