SOURCE

var obj = new Proxy({}, {
    // get
    get: function (target, propKey, receiver) {
        console.log(`getting ${propKey}!`);
        return Reflect.get(target, propKey, receiver);
    },
    // set
    set: function (target, propKey, value, receiver) {
        console.log(`setting ${propKey}!`);
        return Reflect.set(target, propKey, value, receiver);
    }
});
obj.a = 123;
console.log(obj.a)

let myArray = [1, 2, 3, 4, 5, 2, 1];
function getArray(array) {
    let newArray = [];
    let map = new Map();
    for (let i = 0, l = array.length; i < l; i++) {
        if(typeof map.get(array[i]) == "undefined"){map.set(array[i], array[i]
        );            newArray.push(array[i]);        }    
    }return newArray;
}
console.warn(getArray(myArray));
console 命令行工具 X clear

                    
>
console