SOURCE

//排序后的最大差值
const arr = [3, 6, 9, 1];

//排序 计算最大差值
function test(arr) {
    if (arr.length < 2) return 0;
    arr.sort((a, b) => a - b)
    //计算差值
    let max = 0;
    for (let i = 0; i < arr.length - 1; i++) {
        max = Math.max(max, arr[i + 1] - arr[i])
    }
    return max;
}

console.log(test(arr))

//前序遍历二叉树
const tree = [1, null, 2, 3];

const res = [];
//递归
function treeTest(tree) {
    if (tree) {
        res.push(tree.val);
        treeTest(tree.left);
        treeTest(tree.right);
    }
}

treeTest(tree)
console.log(res)

const rs = []
function test01(tree) {
    if (tree.length < 1) return [];
    for (let i = 0; i < tree.length; i++) {
        if (tree[i] != null) {
            rs.push(tree[i])
        }
    }
}

test01(tree)
console.log(rs)

//清楚重复数字

const arry = [1, 1, 1, 2, 2, 2]

function test03(arry) {
    return [...new Set(arry)]
}

console.log('nums=',test03(arry))


let a = [1, 1, 2, 2, 3]
a.splice(0, 1)
console.log(a)
console 命令行工具 X clear

                    
>
console