JavaScript Sorting Arrays

1/21/2020 7:20:24 AM

JavaScript have some pre define method to sort the array my ascending or descending. We also called up to bottom sort or bottom to up sort. This pre defend method very helpful to sort the JavaScript array. We also use reverse method to reverse the array or collection. If we don’t have use the function then the code more than complexes because we write the code explicitly. Now given bellow the example code and explain the code:

<!DOCTYPE html>
<script type="text/javascript">
var human = ["Reza", "Jesy", "Tofile", "Dipto"];
function myFunction() {

Now we can see the sort value of the array by using JavaScript sort method. If we work same but doesn’t use the method it will be more complex code.  So, this type function is responsible to code are easier.