how to remove last element in js


var array = [1, 2, 3, 4, 5, 6];
array.pop();
console.log(array);
//Output in console section:
//[1, 2, 3, 4, 5]

array.pop(); //returns popped element
//example
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop(); // fruits= ["Banana", "Orange", "Apple"];

var colors = ["red","blue","green"];
var green = colors.splice(-1,1); //colors is now ["red", "blue"]

www.codegrepper.com
www.stackoverflow.com