Skip to content
Related Articles

Related Articles

Node.js | pop() function
  • Last Updated : 30 Aug, 2019

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

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

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

[]

Program 3:

filter_none

edit
close

play_arrow

link
brightness_4
code

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


Output:

[ 'java', 'c', 'python' ]
[ 'java', 'c' ]
My Personal Notes arrow_drop_up
Recommended Articles
Page :