js empty an array code example
Example 1: Javascript remove empty elements from array
var colors=["red","blue",,null,undefined,,"green"];
var realColors = colors.filter(function (e) {return e != null;});
console.log(realColors);
Example 2: javascript empty array
arr = [];
const empty = arr => arr.length = 0;
var arr= [1,2,3,4,5];
empty(arr)
Example 3: how to make array empty
A.length = 0
Example 4: empty array js
let list = [1, 2, 3, 4];
function empty() {
list = [];
}
empty();
Example 5: javascript empty array
if (array === undefined || array.length == 0) {
}
Example 6: empty array length javascript
empty array check javascript