remove element from end of array javascript code example
Example 1: remove element from array javascript
//using filter() method => it returns a new array
data = [1, 2, 3, 4, 5, 6];
let filteredData = data.filter((i) => {
return i > 2
});
console.log(filteredData) // [3, 4, 5, 6]
Example 2: javascript delete second last element of array
arr.splice(arr.length - 2, 1);
Example 3: javascript remove last element from array
var arr = [1,0,2];