Q:

remove last element from array javascript

array.pop();   //returns popped element
//example
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop();  // fruits= ["Banana", "Orange", "Apple"];
10
var colors = ["red","blue","green"];
colors.pop();
12
var array = [1, 2, 3, 4, 5, 6];
array.pop();
console.log(array);
//Output in console section:
//[1, 2, 3, 4, 5]
3
array.pop();

// Example
var colors = ['Yellow', 'Red', 'Blue', 'Green'];
var removedColor = colors.pop(); // Green
console.log(colors); // ['Yellow', 'Red', 'Blue']
1
array.splice(-1,1)
0
var pg_url = array_fragment[array_fragment.length - 2]
0
let numbers = [1, 2, 3];
numbers.pop();
0

var fruits = ["Banana", "Orange", "Apple", "Mango"];

fruits.pop();
 
0

New to Communities?

Join the community