javascript clear an array code example
Example 1: javascript copy an array
let arr =["a","b","c"];
const copy = [...arr];
const copy = Array.from(arr);
Example 2: javascript empty array
arr = [];
const empty = arr => arr.length = 0;
var arr= [1,2,3,4,5];
empty(arr)
Example 3: 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 4: javascript array clear
var cars = ["mazda","honda","tesla"];
cars = [];
Example 5: how to clear array in javascript
A.length = 0
Example 6: javascript clear an array
let arr = [3.14, 7];
arr = [];