Program to use JavaScript Array pop() method
let a = ['Good Morning', 'Good Afternoon', 'Good Evening', 'Good Night'];
let b = a.pop();
console.log(b);
Output
Good Night
Steps Description
- Declare two variable
a
andb
- Initialize two variable with value of array
a = ['Good Morning', 'Good Afternoon', 'Good Evening', 'Good Night']
andb = a.pop()
Array pop()
method removes the last element of the array. and returns the removed element- The value of
b
variable is displayed with the help of console.log inbuilt function
Program to use JavaScript Array pop() method
let c = [1,2,3,4,5];
let d = c.pop();
console.log(d);
Output
5
Steps Description
- Declare two variable
c
andd
- Initialize two variable with value of array
c = [1,2,3,4,5]
andd = c.pop()
Array pop()
method removes the last element of the array. and returns the removed element- The value of
d
variable is displayed with the help of console.log inbuilt function