JavaScript Tutorial/Array/Reverse — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:25, 26 мая 2010
Array.reverse()
The reverse() method reverses the order of the elements in the array according to the array index numbers.
<html>
<script language="JavaScript">
<!--
lineOfPeople = new Array("A","B","C");
lineOfPeople.reverse();
document.write("lineOfPeople[0]=",lineOfPeople[0],"<br>");
document.write("lineOfPeople[1]=",lineOfPeople[1],"<br>");
document.write("lineOfPeople[2]=",lineOfPeople[2],"<br>");
-->
</script>
</html>
Reverse the elements in an Array
<html>
<head>
<title>Reverse an Array</title>
<script language="javascript" type="text/javascript">
<!--
var x = new Array(2,3,4);
x.reverse();
alert(x);
//-->
</script>
</head>
<body>
</body>
</html>