javascript remove all elements from array code example
Example 1: javascript empty array
arr = [];
const empty = arr => arr.length = 0;
var arr= [1,2,3,4,5];
empty(arr)
Example 2: js array delete specific element
var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
var filtered = array.filter(function(value, index, arr){
return value > 5;
});
Example 3: js delete all array items
A.splice(0,A.length)
Example 4: empty array js
let list = [1, 2, 3, 4];
function empty() {
list = [];
}
empty();
Example 5: empty array js
let list = [1, 2, 3, 4];
function empty() {
list.length = 0;
}
empty();