JS Array Sort & Reverse


Sorting an Array

<!DOCTYPE html>
<html>
<head>
  <title>JavaScript</title>
  <script>
    var a = ["Sanjay","Aman","Rehman","Karan"];
       
    document.write(a + "<br><br>");
    a.sort();
    document.write(a);
  </script>
</head>
<body>
</body>
</html>


Reversing an Array

<!DOCTYPE html>
<html>
<head>
  <title>JavaScript</title>
  <script>
    var b = ["Sanjay", "Aman", "Rehman", "Karan"];

    document.write(b + "<br><br>");
    b.reverse();
    document.write(b);
  </script>
</head>
<body>
</body>
</html>