typescript clear 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: javascript array clear
var cars = ["mazda","honda","tesla"];
cars = [];
Example 3: empty array js
let list = [1, 2, 3, 4];
function empty() {
list = [];
}
empty();
Example 4: empty array js
let list = [1, 2, 3, 4];
function empty() {
list.length = 0;
}
empty();
Example 5: typescript clear array
const array: Array<number> = new Array<number>();
array.push(1);
array.push(2);
array.push(3);
array.push(4);
array = [];