1array.pop(); //returns popped element
2//example
3var fruits = ["Banana", "Orange", "Apple", "Mango"];
4fruits.pop(); // fruits= ["Banana", "Orange", "Apple"];
1var array = [1, 2, 3, 4, 5, 6];
2array.pop();
3console.log(array);
4//Output in console section:
5//[1, 2, 3, 4, 5]
1// Method - 1
2var arr = [1, 2, 3, 4, 5];
3
4var last = arr.pop();
5console.log(arr);
6/*
7 Output: [ 1, 2, 3, 4 ]
8*/
9
10// Method - 2
11var arr = [1, 2, 3, 4, 5];
12
13arr.splice(arr.length - 1);
14console.log(arr);
15/*
16 Output: [ 1, 2, 3, 4 ]
17*/
18
19// Method - 3
20var _ = require("lodash");
21
22var arr = [1, 2, 3, 4, 5];
23arr = _.initial(arr);
24console.log(arr);
25/*
26 Output: [ 1, 2, 3, 4 ]
27*/
28
29// Method - 4
30var _ = require("underscore");
31
32var arr = [1, 2, 3, 4, 5];
33var n = 3;
34
35arr = _.initial(arr, n);
36console.log(arr);
37/*
38 Output: [ 1, 2 ]
39*/
1var fruits = ["Banana", "Orange", "Apple", "Mango"];
2document.write(fruits);
3document.write("<br>");
4fruits.pop();
5
6document.write(fruits)