SOURCE

const obj = {
    name:
    {
        age: 10
    },
    arr: [
        1, 2, 3, 4, 5
    ],
    title: 'title'
};
// JSON.stringify
const depthCopy = (target) => {
    const result = Array.isArray(target) ? [] : {};

    const entr = Object.entries(target);
    const len = entr.length;

    for (let i = 0; i < len; i++) {
        const [key, value] = entr[i];
        if (typeof value === 'object') {
            result[key] = depthCopy(value);
        } else {
            result[key] = value;
        }
    }

    return result;
};
const test1 = depthCopy(obj);
obj.name.age = 100;
// console.log(test1, obj);

const myAllSettled = (promiseArr) => {
    const len = promiseArr.length;
    const result = [];
    let count = 0;

    return new Promise((resolve, reject) => {
        for (let i = 0; i < len; i++) {
            promiseArr[i].then((res) => {
                result[i] = res;
                count += 1;
                if (count === len) {
                    return resolve(result);
                }

            }).catch((e) => {
                result[i] = e;
                count += 1;
                if (count === len) {
                    return resolve(result);
                }
            })
        }
    })
};

const randomFn = (max, min) => {
    return (Math.random() * (max - min) + min) | 0;//
}
const testArr = [2, 1, 5, 7, 3, 9, 0];

console 命令行工具 X clear

                    
>
console