Remove elements from array by changing the array length : Array Length : Array JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Array » Array Length »

 

Remove elements from array by changing the array length

















<html>
<head>
<title>Removing Elements</title>

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

var x = new Array(0,1,2,3,4);

var firstElement  = x[x.length-1];
x.length = x.length-1;

var secondElement = x[x.length-1];
x.length = x.length-1;

alert(firstElement)
alert(secondElement)
alert(x);

//-->
</script>

</head>
<body>

<h1>Removing Elements</h1>

</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Array
» Array Length