empty array js

JavaScript
let list = [1, 2, 3, 4];
function empty() {
    //empty your array
    list.length = 0;
}
empty();
var colors = ["red","blue","green"];
    colors = []; //empty the arrayvar list = [1, 2, 3, 4];
function empty() {
    //empty your array
    list.length = 0;
}
empty();
// define Array
let list = [1, 2, 3, 4];
function empty() {
    //empty your array
    list = [];
}
empty();
const colors = ["red","blue","green"];
colors.lenght = 0;
Source

Also in JavaScript: