Mega Code Archive

 
Categories / JavaScript DHTML / Language Basics
 

Reversing, Sorting, and Concatenating an Array

<HTML> <HEAD> <TITLE>  Array methods  </TITLE> <HEAD> <BODY> <H1> <SCRIPT>      var theArray = new Array("N","M","T","M");      document.write ("Original array: " + theArray);      document.write ("<br>");      theArray.reverse();      document.write ("Reversed array: " + theArray);      document.write ("<br>");      theArray.sort();      document.write ("Sorted array: " + theArray);      document.write ("<br>");      document.write("Concatenated: " + theArray.concat("Cypher", "Mouse"));      </SCRIPT> </H1> </BODY> </HTML>