Find the second smallest number in array JavaScript | Example code

If performance doesn’t bother you then simply sort the array and get the 1 index value of array to get second smallest number in array JavaScript.

Find the second smallest number in array JavaScript Example

HTML example code:

Sort method will update existing array in increasing order.

Output:

Find the second smallest number in array JavaScript

Note: Array index is start from 0.

Do comment if you have any doubt and suggesiton on this JS array topic.

Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.