|
|
Pop() to remove last element of an array - Javascript
|
Views : 437
|
|
Tagged in : Javascript
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
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 |
|
|
|