by hackrmn · 7mo ago · 0 comments
class Age {
#value;
constructor(value) {
if(typeof value != "number") throw new Error("Not a number");
this.#value = value;
}
} let x = new Age();
x.notSoOpaque = 42;
console.log(x.notSoOpaque);
We can all agree to layer conventions on top of the language so we just don’t do stuff that violates the opacity. But the same is true of assembly language.