3.6.2 数组去重

export function unique(arr) {
    let result = [], hash = {};
    for (let i = 0, elem; (elem = arr[i]) != null; i++) {
        if (!hash[elem]) {
            result.push(elem);
            hash[elem] = true;
        }
    }
    return result;
}
该文件修订时间: 2021-01-14 15:02:10

results matching ""

    No results matching ""