let pro = new Proxy({
add: function (val) {
return val + 100;
},
name: 'i am '
}, {
get: function (target, key, property) {
console.log('come in get')
return target[key]
},
set: function (target, key, value, receiver) {
console.log(`setting ${key}=${value}`)
return target[key]=value;
}
})
console.log(pro.name)
pro.name = 'ceshi'
console.log(pro.name)
let target = function () {
return 'im'
}
let handler = {
apply(target, ctx, args) {
console.log('do apply')
return Reflect.apply(...arguments)
}
}
let pro = new Proxy(target, handler);
console.log(pro())