Artemko
Apr 19, 2022

I don't really get the reason why Proxies are exist in JS.

Basically, why I have to use this:

const target = {

name: "test"

};

const handler = {

get(target, prop, receiver) {

return target.name ?? "";

}

};

const proxy = new Proxy(target, handler );

console.log(proxy.name);

instead of this:

const a = {

value: {

name: "test"

},

get name() {

return this.value.name;

}

};

console.log(a.name);

???

Artemko
Artemko

Written by Artemko

Software Engineer with experience.

No responses yet