JSFiddle - React, Tailwind, and code Playground

by tlgreg

JavaScript

function DataProxy() {}
DataProxy.prototype = new Proxy({}, {
	get(t, prop, r) {
  	return `foo: ${t[prop]}`
  },
  set(t, prop, val, r) {
  	t[prop] = val
  },
})

class Model extends DataProxy {}

class Dog extends Model {
	constructor() {
  	this.abc = 'zed'
  }
  bark() {
  	console.log('barkn')
  }
}

let d = new Dog()
d.bark()
d.abc = 'def'
console.log(d.abc)