Entfernen Sie das letzte Element aus Array JavaScript
array.splice(-1,1)
Innocent Iguana
array.splice(-1,1)
Array.pop()
var colors = ["red","blue","green"];
colors.pop();
array.pop(); //returns popped element
//example
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.pop(); // fruits= ["Banana", "Orange", "Apple"];
array.pop();
var arr = [1,2,3,4];
console.log(arr.splice(0,arr.length-1));
Run code snippetHide results