echmaScript proxy

Estimated reading time: 1 minute

What is proxy?

In JavaScript, a proxy is an object that controls access to another object, called the target object. You can use a proxy to intercept and modify the behavior of operations performed on the target object, such as getting and setting properties, calling methods, and creating new objects.

~ courtesy chatgpt


let user = {name: 'kamal', age: 21}

let handler = {
  get(target, name){
    return target[name].toUpperCase()
  set(target, name, value) {
    if(typeof value === 'string') {
      target[name] = value.trim().toUpperCase();

let userProxy = new Proxy(user,handler) = 'mostafa'



es, es6, js, es6_proxy