by @kodeazy

JavaScript How to get second smallest element from an array?

Home » javascript » JavaScript How to get second smallest element from an array?
  • I have an array and to get the second smallest element sort them in asc and got the element by its index
  • Below is an example

    ['30','123','141','235','44','27'].sort(function(a, b) { return a- b; })[1];

    Output:

    30