JSFiddle - React, Tailwind, and code Playground

by Joe Pea

JavaScript

class Foo {}

Foo.prototype = new Proxy(Foo.prototype, {
  get(_, prop, self) {
  	console.log('get', self.constructor.name, prop)
    return self[prop]
  },
  set(_, prop, value, self) {
    console.log('set', self.constructor.name, prop, value)
    self[prop] = value
    return true
  },
})

class Bar extends Foo {}

console.log('Expect to see output after this:')

const f = new Foo
f.foo = 'foo'
f.foo

const b = new Bar
b.bar = 'bar'
b.bar