array split and remove last item code example
Example 1: javascript remove first item from array
var colors = ["red", "green", "blue"];
var red=colors.shift();
//colors is now ["green","blue"];
Example 2: how to get last item in array javascript
let nums = [1,2,3,4,5];
let lastOne = nums.pop();
// -> lastOne = 5
// -> nums = [1,2,3,4];