clear an array in javascript 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: javascript clear array
let aray = [1,2,3,4,5,6,7,8,9,10];
array = [];
array.length = 0;
array.splice(0, array.length);
array.map( () => array.pop());
array.map( () => array.shift());
Example 3: javascript array clear
var cars = ["mazda","honda","tesla"];
cars = [];
Example 4: how to clear array in javascript
A.length = 0
Example 5: js delete all from array
var list = [1, 2, 3, 4];
function empty() {
list.length = 0;
}
empty();
Example 6: javascript clear an array
let arr = [3.14, 7];
arr = [];