Answered by : reagan-mcfarland
if (array === undefined || array.length == 0) { // array empty or does not exist
}
Source : | Last Update : Sat, 12 Sep 20
Answered by : vikas
arr = []; // set array=[]
//function
const empty = arr => arr.length = 0;
//example
var arr= [1,2,3,4,5];
empty(arr) // arr=[]
Source : https://1loc.dev/#compare-two-arrays-regardless-of-order | Last Update : Thu, 09 Jul 20
Answered by : code-grepper
var colors=[];
if(!colors.length){ // I am empty
}else{ // I am not empty
}
Source : | Last Update : Tue, 12 Nov 19
Answered by : code-grepper
var colors = ["red","blue","green"]; colors = []; //empty the array
Source : | Last Update : Tue, 29 Oct 19
Answered by : ilham-surya
arr = [];
Source : https://www.tutorialspoint.com/in-javascript-how-to-empty-an-array | Last Update : Sat, 05 Mar 22
Answered by : philani-sithembiso-ndhlela
let list = [1, 2, 3, 4];
function empty() { //empty your array list.length = 0;
}
empty();
Source : https://www.jstips.co/en/javascript/two-ways-to-empty-an-array/ | Last Update : Mon, 08 Jun 20
Answered by : distinct-dotterel-lhrq2rbi87v3
A = [];
Source : https://stackoverflow.com/questions/1232040/how-do-i-empty-an-array-in-javascript | Last Update : Fri, 30 Oct 20
Answered by : philani-sithembiso-ndhlela
// define Array
let list = [1, 2, 3, 4];
function empty() { //empty your array list = [];
}
empty();
Source : https://www.jstips.co/en/javascript/two-ways-to-empty-an-array/ | Last Update : Mon, 08 Jun 20
Answered by : gbor-deutsch
let myArray = [12 , 222 , 1000 ];
myArray.length = 0; // myArray will be equal to [].
Source : https://stackoverflow.com/questions/1232040/how-do-i-empty-an-array-in-javascript | Last Update : Fri, 27 Nov 20
Answered by : modern-mouse
A.length = 0
Source : https://stackoverflow.com/questions/1232040/how-do-i-empty-an-array-in-javascript | Last Update : Sat, 06 Jun 20