JSFiddle - React, Tailwind, and code Playground
by Josh Pullen
JavaScript
class Test {
constructor() {
this._color = { r: 255, g: 0, b: 0 }
}
get color() {
return {
r: this._color.r,
g: this._color.g,
b: this._color.b,
h: this._color.r / 2,
s: this._color.g / 2,
l: this._color.b / 2
}
}
set color(value) {
console.log("Setting: ", value);
}
}
const test = new Test();
test.color.g = 255;
console.log(test.color);