Use Array.pop() to return last element in an array : Pop « Array « JavaScript Tutorial






<html>
<head>
<title>Last Element Returned</title>

<script language="javascript" type="text/javascript">
<!--

var x = new Array("a","b","c","d");
var lastEl = x.pop();
alert(x.length);
alert(lastEl);

//-->
</script>

</head>
<body>

<h1>Last Element Returned</h1>

</body>
</html>








11.20.Pop
11.20.1.Array.pop()
11.20.2.Use Array.pop() to return last element in an array
11.20.3.Using pop method from zArray Library