Node.js | pop() function
pop() is an array function from Node.js that is used to remove elements from the end of an array.
Syntax:
array_name.pop()
Parameter: This function does not takes any parameter.
Return type: The function returns the array.
The program below demonstrates the working of the function:
Program 1:
function POP() { arr.pop(); console.log(arr); } var arr = [1,2,3,4,5,6,7]; POP(); |
chevron_right
filter_none
Output:
[ 1, 2, 3, 4, 5, 6 ]
Program 2:
function POP() { arr.pop(); console.log(arr); } var arr = ['GFG']; POP(); |
chevron_right
filter_none
Output:
[]
Program 3:
var Lang = ['java', 'c', 'python']; console.log(Lang); // expected output: Array [ 'java', 'c', 'python' ] Lang.pop(); console.log(Lang); // expected output: Array [ 'java', 'c' ] |
chevron_right
filter_none
Output:
[ 'java', 'c', 'python' ] [ 'java', 'c' ]
Recommended Posts:
- Nodejs | Automatic restart NodeJs server with nodemon
- Nodejs | DNS
- Web-Socket in NodeJS
- Nodejs | DNS | setServers()
- Nodejs | Jimp
- Nodejs | Web Crawling using Cheerio
- Difference between NodeJS and AngularJS
- Dockerizing a simple Nodejs app
- Encrypting Data in NodeJS
- Nodejs – Connect Mysql with Node app
- NodeJs - Handling invalid routes
- Cowsay in Nodejs using Requests library
- Signup Form Using Nodejs and MongoDB
- NodeJS | Building simple REST API in express
- Nodejs - Connect MongoDB with Node app using MongooseJS
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



