SOURCE

function compact(array){
    if(array === null){
        return []
    }
    let result = [],idx = 0;
    for(const value of array){
        if(value){
            result[idx++] = value
        }
    }
    return result;
}
console 命令行工具 X clear

                    
>
console