JavaScript pop() Method
Definition and Usage
The pop()
method removes (pops) the last element of an array.
The pop()
method changes the original array.
The pop()
method returns the removed element.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>JavaScript Array pop() Method</h1>
<script>
const myNumbers = [1, 4, 8, 4];
console.log(myNumbers);
console.log(myNumbers.pop());
console.log(myNumbers);
</script>
</body>
</html>
Comments
Post a Comment