Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Node.js pop() function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 take any parameter. 

Return type: The function returns the array. The program below demonstrates the working of the function: 

Example 1:

javascript




function POP() {
    arr.pop();
    console.log(arr);
}
const arr = [1, 2, 3, 4, 5, 6, 7];
POP();


Output:

[ 1, 2, 3, 4, 5, 6 ]

Example 2:

javascript




function POP() {
    arr.pop();
    console.log(arr);
}
const arr = ['GFG'];
POP();


Output:

[]

Example 3: 

javascript




const Lang = ['java', 'c', 'python'];
 
console.log(Lang);
// expected output: Array [ 'java', 'c', 'python' ]
 
Lang.pop();
 
console.log(Lang);
// expected output: Array [ 'java', 'c' ]


Output:

[ 'java', 'c', 'python' ]
[ 'java', 'c' ]

My Personal Notes arrow_drop_up
Last Updated : 30 Mar, 2023
Like Article
Save Article
Similar Reads
Related Tutorials