Array.reverse() Method : Array : Language Basics JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Language Basics » Array »

 

Array.reverse() Method



<HTML>
<HEAD>
<TITLE>Array.reverse()</TITLE>
<SCRIPT LANGUAGE="JavaScript1.1">
solarSys = new Array(9)
solarSys[0"M"
solarSys[1"V"
solarSys[2"E"
solarSys[3"M"
solarSys[4"J"
solarSys[5"S"
solarSys[6"U"
solarSys[7"N"
solarSys[8"P"


function showAsIs(form) {
    var delimiter = form.delim.value
    form.output.value = unescape(solarSys.join(delimiter))
}


function reverseIt(form) {
    var delimiter = form.delim.value
    solarSys.reverse()  
    form.output.value = unescape(solarSys.join(delimiter))
}
</SCRIPT>
<BODY>
<H2>Reversing array element order</H2>
<FORM>
Enter a string to act as a delimiter between entries:
<INPUT TYPE="text" NAME="delim" VALUE="," SIZE=5><P>
<INPUT TYPE="button" VALUE="Array as-is" onClick="showAsIs(this.form)">
<INPUT TYPE="button" VALUE="Reverse the array" onClick="reverseIt(this.form)">
<INPUT TYPE="reset">
<INPUT TYPE="button" VALUE="Reload" onClick="self.location.reload()">
<TEXTAREA NAME="output" ROWS=COLS=60>
</TEXTAREA>
</FORM>
</BODY>
</HTML>


           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Language Basics
» Array