empty array js

JavaScript
arr = [];   // set array=[]

//function
const empty = arr => arr.length = 0;
//example
var arr= [1,2,3,4,5];
empty(arr) // arr=[]var colors = ["red","blue","green"];
    colors = []; //empty the array// define Array
let list = [1, 2, 3, 4];
function empty() {
    //empty your array
    list = [];
}
empty();
let list = [1, 2, 3, 4];
function empty() {
    //empty your array
    list.length = 0;
}
empty();
var list = [1, 2, 3, 4];
function empty() {
    //empty your array
    list.length = 0;
}
empty();
if (array === undefined || array.length == 0) {
    // array empty or does not exist
}
Source

Also in JavaScript: