Home > Web Front-end > CSS Tutorial > How to use pop method

How to use pop method

不言
Release: 2021-04-20 14:32:59
Original
14109 people have browsed it

The function of the pop method is to delete the last element from the array and return the element. Its usage syntax is "array.pop();". This method can also reduce the length or size of the array by one.

How to use pop method

The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.

The pop() method of Javascript array can remove the last element from the array and return that element. In this way, the length or size of the array will also be reduced by one. Let's take a closer look at the use of the pop method in How to use pop method.

Let’s first look at the basic syntax of the pop method

array.pop();
Copy after login

Then let’s look at specific examples of using the pop method

The code is as follows

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
</head>
<body>
<script type="text/javascript">
var scripts = new Array();
scripts[0] = "PHP";
scripts[1] = "ASP";
scripts[2] = "How to use pop method";
scripts[3] = "HTML";
document.write(scripts.join(" <br> "));
document.write("<br>--使用pop()方法后的结果--<br>");
scripts.pop();
document.write(scripts.join(" <br> "));
</script>
</body>
</html>
Copy after login

The display effect on the browser is as follows

How to use pop method

The last element HTML is deleted from the array.

This article ends here. For more exciting content, you can pay attention to the relevant column tutorials on the PHP Chinese website! ! !

The above is the detailed content of How to use pop method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
pop
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template