Pop() to remove last element of an array - Javascript Views : 483
Tagged in : Javascript
0 0
Send mail
Pop() to remove last element of an array

We can remove the last element of the array by applying pop() method to the JavaScript function.

Here is the syntax of applying pop() method to an array

Syntax:
scripts.pop();


Example:

<script type="text/javascript">
var scripts = new Array();
scripts[0] = "Domain";
scripts[1] = "Hosting";
scripts[2] = "FreeTemplates";
scripts[3] = "Javascript";
document.write(scripts.join(" <br> "));
document.write("<br>--Now after applying pop()--<br>");
scripts.pop();
document.write(scripts.join(" <br> "));

</script>


Result:

Domain
Hosting
FreeTemplates
JAvascript
--Now after applying pop()--
Domain
Hosting
FreeTemplates


By Sanju, On - 2009-12-11



    Login to add Comments .